From 4b138f163b6cf49812d542f62c1fd384f1830ffa Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 3 Sep 2021 09:22:14 +0100 Subject: [PATCH] CI: notify GH check status in start cloud stages --- Jenkinsfile | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3d552c4a4d0..ae803f909cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -278,9 +278,9 @@ def generateStages(Map args = [:]) { def cloud(Map args = [:]) { withNode(labels: args.label, forceWorkspace: true){ - startCloudTestEnv(name: args.directory, dirs: args.dirs) + startCloudTestEnv(name: args.directory, dirs: args.dirs, context: args.context) } - withCloudTestEnv() { + withCloudTestEnv(args) { try { target(context: args.context, command: args.command, directory: args.directory, label: args.label, withModule: args.withModule, isMage: true, id: args.id) } finally { @@ -834,32 +834,34 @@ def tarAndUploadArtifacts(Map args = [:]) { * This method executes a closure with credentials for cloud test * environments. */ -def withCloudTestEnv(Closure body) { +def withCloudTestEnv(Map args = [:], Closure body) { def maskedVars = [] def testTags = "${env.TEST_TAGS}" - // AWS - if (params.allCloudTests || params.awsCloudTests) { - testTags = "${testTags},aws" - def aws = getVaultSecret(secret: "${AWS_ACCOUNT_SECRET}").data - if (!aws.containsKey('access_key')) { - error("${AWS_ACCOUNT_SECRET} doesn't contain 'access_key'") - } - if (!aws.containsKey('secret_key')) { - error("${AWS_ACCOUNT_SECRET} doesn't contain 'secret_key'") + withGithubNotify(context: "${args.context}") { + // AWS + if (params.allCloudTests || params.awsCloudTests) { + testTags = "${testTags},aws" + def aws = getVaultSecret(secret: "${AWS_ACCOUNT_SECRET}").data + if (!aws.containsKey('access_key')) { + error("${AWS_ACCOUNT_SECRET} doesn't contain 'access_key'") + } + if (!aws.containsKey('secret_key')) { + error("${AWS_ACCOUNT_SECRET} doesn't contain 'secret_key'") + } + maskedVars.addAll([ + [var: "AWS_REGION", password: "${env.AWS_REGION}"], + [var: "AWS_ACCESS_KEY_ID", password: aws.access_key], + [var: "AWS_SECRET_ACCESS_KEY", password: aws.secret_key], + ]) } - maskedVars.addAll([ - [var: "AWS_REGION", password: "${env.AWS_REGION}"], - [var: "AWS_ACCESS_KEY_ID", password: aws.access_key], - [var: "AWS_SECRET_ACCESS_KEY", password: aws.secret_key], - ]) - } - withEnv([ - "TEST_TAGS=${testTags}", - ]) { - withEnvMask(vars: maskedVars) { - body() + withEnv([ + "TEST_TAGS=${testTags}", + ]) { + withEnvMask(vars: maskedVars) { + body() + } } } } @@ -878,7 +880,7 @@ def startCloudTestEnv(Map args = [:]) { String name = normalise(args.name) def dirs = args.get('dirs',[]) stage("${name}-prepare-cloud-env"){ - withCloudTestEnv() { + withCloudTestEnv(args) { withBeatsEnv(archive: false, withModule: false) { try { dirs?.each { folder ->