@@ -277,13 +277,13 @@ def generateStages(Map args = [:]) {
277277def cloud (Map args = [:]) {
278278 withGithubNotify(context : args. context) {
279279 withNode(labels : args. label, forceWorkspace : true ){
280- startCloudTestEnv(name : args. directory, dirs : args. dirs)
280+ startCloudTestEnv(name : args. directory, dirs : args. dirs, withAWS : args . withAWS )
281281 }
282- withCloudTestEnv() {
282+ withCloudTestEnv(args ) {
283283 try {
284284 target(context : args. context, command : args. command, directory : args. directory, label : args. label, withModule : args. withModule, isMage : true , id : args. id)
285285 } finally {
286- terraformCleanup(name : args. directory, dir : args. directory)
286+ terraformCleanup(name : args. directory, dir : args. directory, withAWS : args . withAWS )
287287 }
288288 }
289289 }
@@ -851,14 +851,15 @@ def tarAndUploadArtifacts(Map args = [:]) {
851851* This method executes a closure with credentials for cloud test
852852* environments.
853853*/
854- def withCloudTestEnv (Closure body ) {
854+ def withCloudTestEnv (Map args = [:], Closure body ) {
855855 def maskedVars = []
856856 def testTags = " ${ env.TEST_TAGS} "
857857
858858 // Allow AWS credentials when the build was configured to do so with:
859859 // - the cloudtests build parameters
860860 // - the aws github label
861- if (params. allCloudTests || params. awsCloudTests || matchesPrLabel(label : ' aws' )) {
861+ // - forced with the cloud argument aws github label
862+ if (params. allCloudTests || params. awsCloudTests || matchesPrLabel(label : ' aws' ) || args. get(' withAWS' , false )) {
862863 testTags = " ${ testTags} ,aws"
863864 def aws = getVaultSecret(secret : " ${ AWS_ACCOUNT_SECRET} " ). data
864865 if (! aws. containsKey(' access_key' )) {
@@ -872,6 +873,7 @@ def withCloudTestEnv(Closure body) {
872873 [var : " AWS_ACCESS_KEY_ID" , password : aws. access_key],
873874 [var : " AWS_SECRET_ACCESS_KEY" , password : aws. secret_key],
874875 ])
876+ log(level : ' INFO' , text : ' withCloudTestEnv: it has been configured to run in AWS.' )
875877 }
876878
877879 withEnv([
@@ -897,7 +899,7 @@ def startCloudTestEnv(Map args = [:]) {
897899 String name = normalise(args. name)
898900 def dirs = args. get(' dirs' ,[])
899901 stage(" ${ name} -prepare-cloud-env" ){
900- withCloudTestEnv() {
902+ withCloudTestEnv(args ) {
901903 withBeatsEnv(archive : false , withModule : false ) {
902904 try {
903905 dirs?. each { folder ->
@@ -940,7 +942,7 @@ def terraformCleanup(Map args = [:]) {
940942 String name = normalise(args. name)
941943 String directory = args. dir
942944 stage(" ${ name} -tear-down-cloud-env" ){
943- withCloudTestEnv() {
945+ withCloudTestEnv(args ) {
944946 withBeatsEnv(archive : false , withModule : false ) {
945947 unstash(" terraform-${ name} " )
946948 retryWithSleep(retries : 2 , seconds : 5 , backoff : true ) {
@@ -1065,6 +1067,7 @@ class RunCommand extends co.elastic.beats.BeatsFunction {
10651067 public run (Map args = [:]){
10661068 steps. stageStatusCache(args){
10671069 def withModule = args. content. get(' withModule' , false )
1070+ def withAWS = args. content. get(' withAWS' , false )
10681071 //
10691072 // What's the retry policy for fighting the flakiness:
10701073 // 1) Lint/Packaging/Cloud/k8sTest stages don't retry, since their failures are normally legitim
@@ -1123,7 +1126,7 @@ class RunCommand extends co.elastic.beats.BeatsFunction {
11231126 steps. k8sTest(context : args. context, versions : args. content. k8sTest. split(' ,' ), label : args. label, id : args. id)
11241127 }
11251128 if (args?. content?. containsKey(' cloud' )) {
1126- steps. cloud(context : args. context, command : args. content. cloud, directory : args. project, label : args. label, withModule : withModule, dirs : args. content. dirs, id : args. id)
1129+ steps. cloud(context : args. context, command : args. content. cloud, directory : args. project, label : args. label, withModule : withModule, dirs : args. content. dirs, id : args. id, withAWS : withAWS )
11271130 }
11281131 }
11291132 }
0 commit comments