Skip to content

Commit

Permalink
CI: notify GH check status in start cloud stages
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Sep 3, 2021
1 parent 825bfb2 commit 4b138f1
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
}
}
}
Expand All @@ -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 ->
Expand Down

0 comments on commit 4b138f1

Please sign in to comment.