From 39446d400697cf9959a843c21c7af75c02bc3bb3 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Tue, 5 Apr 2022 16:23:55 -0700 Subject: [PATCH] Update new docker jobs to make ECR optional (#1859) * update docker jobs with boolean ECR option Signed-off-by: Abhinav Gupta * change expression Signed-off-by: Abhinav Gupta * update when condition Signed-off-by: Abhinav Gupta * update when condition Signed-off-by: Abhinav Gupta * update description Signed-off-by: Abhinav Gupta * updated job to have dropdown for ecr and dockerhub Signed-off-by: Abhinav Gupta * update default Signed-off-by: Abhinav Gupta * update default Signed-off-by: Abhinav Gupta * updated the job timeout to be 1 hour Signed-off-by: Abhinav Gupta * update regression files Signed-off-by: Abhinav Gupta --- .../docker-build-with-ecr.jenkinsfile | 13 ++++++- .../docker-ecr/docker-ecr-promote.jenkinsfile | 13 ++++++- ...TestDockerBuildWithDockerhubOnlyJob.groovy | 35 +++++++++++++++++++ .../jenkins/TestDockerBuildWithEcrJob.groovy | 20 ++++++++--- ...stDockerPromoteWithDockerhubOnlyJob.groovy | 34 ++++++++++++++++++ ...ockerPromoteWithEcrAndDockerhubJob.groovy} | 9 ++--- .../TestDockerPromoteWithEcrOnlyJob.groovy | 35 +++++++++++++++++++ ...-build-with-dockerhub-only.jenkinsfile.txt | 22 ++++++++++++ ...-build-with-ecr-dockerhub.jenkinsfile.txt} | 2 +- ...docker-build-with-only-ecr.jenkinsfile.txt | 23 ++++++++++++ ...romote-with-ECR-dockerhub.jenkinsfile.txt} | 2 +- ...-ecr-promote-with-ECR-only.jenkinsfile.txt | 21 +++++++++++ ...romote-with-dockerhub-only.jenkinsfile.txt | 22 ++++++++++++ 13 files changed, 239 insertions(+), 12 deletions(-) create mode 100644 tests/jenkins/TestDockerBuildWithDockerhubOnlyJob.groovy create mode 100644 tests/jenkins/TestDockerPromoteWithDockerhubOnlyJob.groovy rename tests/jenkins/{TestDockerPromoteJob.groovy => TestDockerPromoteWithEcrAndDockerhubJob.groovy} (81%) create mode 100644 tests/jenkins/TestDockerPromoteWithEcrOnlyJob.groovy create mode 100644 tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-dockerhub-only.jenkinsfile.txt rename tests/jenkins/jenkinsjob-regression-files/docker-ecr/{docker-build-with-ecr.jenkinsfile.txt => docker-build-with-ecr-dockerhub.jenkinsfile.txt} (97%) create mode 100644 tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-only-ecr.jenkinsfile.txt rename tests/jenkins/jenkinsjob-regression-files/docker-ecr/{docker-ecr-promote.jenkinsfile.txt => docker-ecr-promote-with-ECR-dockerhub.jenkinsfile.txt} (98%) create mode 100644 tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-only.jenkinsfile.txt create mode 100644 tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-dockerhub-only.jenkinsfile.txt diff --git a/jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile b/jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile index a1cc23d1ca..3ce30ef13b 100644 --- a/jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile +++ b/jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile @@ -2,7 +2,7 @@ lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm)) pipeline { options { - timeout(time: 3, unit: 'HOURS') + timeout(time: 1, unit: 'HOURS') } agent { docker { @@ -39,6 +39,11 @@ pipeline { description: 'Image tag on staging. Eg: 1.3.0', trim: true ) + choice( + choices: ['docker-hub + ECR', 'docker-hub', 'ECR'], + name: 'PLATFORM', + description: 'Where do you want to push the images?' + ) } stages { stage('check-params') { @@ -53,6 +58,9 @@ pipeline { } } stage('docker-build-dockerhub-staging') { + when{ + expression { PLATFORM == 'docker-hub + ECR' || PLATFORM == 'docker-hub' } + } steps { script { git url: DOCKER_BUILD_GIT_REPOSITORY, branch: DOCKER_BUILD_GIT_REPOSITORY_REFERENCE @@ -67,6 +75,9 @@ pipeline { } } stage('docker-ecr-staging') { + when { + expression { PLATFORM == 'docker-hub + ECR' || PLATFORM == 'ECR' } + } steps { script { copyContainer( diff --git a/jenkins/docker-ecr/docker-ecr-promote.jenkinsfile b/jenkins/docker-ecr/docker-ecr-promote.jenkinsfile index fa214bee3c..e82932efd0 100644 --- a/jenkins/docker-ecr/docker-ecr-promote.jenkinsfile +++ b/jenkins/docker-ecr/docker-ecr-promote.jenkinsfile @@ -2,7 +2,7 @@ lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm)) pipeline { options { - timeout(time: 3, unit: 'HOURS') + timeout(time: 1, unit: 'HOURS') } agent { docker { @@ -22,10 +22,18 @@ pipeline { description: 'Image tag on staging. Eg: 1.3.0', trim: true ) + choice( + choices: ['docker-hub + ECR', 'docker-hub', 'ECR'], + name: 'PLATFORM', + description: 'Where do you want to push the images?' + ) } stages { stage('dockerhub-promote-to-prod') { + when{ + expression { PLATFORM == 'docker-hub + ECR' || PLATFORM == 'docker-hub' } + } steps { script { copyContainer( @@ -38,6 +46,9 @@ pipeline { } } stage('ecr-promote-to-prod') { + when { + expression { PLATFORM == 'docker-hub + ECR' || PLATFORM == 'ECR' } + } steps { script { copyContainer( diff --git a/tests/jenkins/TestDockerBuildWithDockerhubOnlyJob.groovy b/tests/jenkins/TestDockerBuildWithDockerhubOnlyJob.groovy new file mode 100644 index 0000000000..883e7ec8a9 --- /dev/null +++ b/tests/jenkins/TestDockerBuildWithDockerhubOnlyJob.groovy @@ -0,0 +1,35 @@ +import jenkins.tests.BuildPipelineTest +import org.junit.Before +import org.junit.Test + +class TestDockerBuildWithDockerhubOnlyJob extends BuildPipelineTest { + + @Before + void setUp() { + + String imageRepository = 'ci-runner-staging' + String imageTag = 'latest' + String accountName = 'aws_account_public' + + super.setUp() + binding.setVariable('IMAGE_REPOSITORY', imageRepository) + binding.setVariable('IMAGE_TAG', imageTag) + binding.setVariable('DOCKER_BUILD_SCRIPT_WITH_COMMANDS', 'dummy_command') + binding.setVariable('AWS_ACCOUNT_PUBLIC', accountName) + binding.setVariable('PLATFORM', 'docker-hub') + + } + + @Test + public void testDockerWithDockerhubOnlyJobStaging(){ + + binding.setVariable('DOCKER_USERNAME ', 'docker_username') + binding.setVariable('DOCKER_PASSWORD', 'docker_password') + + helper.registerAllowedMethod("git", [Map]) + + super.testPipeline("jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile", + "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-dockerhub-only.jenkinsfile") + } + +} diff --git a/tests/jenkins/TestDockerBuildWithEcrJob.groovy b/tests/jenkins/TestDockerBuildWithEcrJob.groovy index 5e5b455388..56c7bc6565 100644 --- a/tests/jenkins/TestDockerBuildWithEcrJob.groovy +++ b/tests/jenkins/TestDockerBuildWithEcrJob.groovy @@ -22,19 +22,31 @@ class TestDockerBuildWithEcrJob extends BuildPipelineTest { binding.setVariable('IMAGE_TAG', imageTag) binding.setVariable('DOCKER_BUILD_SCRIPT_WITH_COMMANDS', 'dummy_command') binding.setVariable('AWS_ACCOUNT_PUBLIC', accountName) + } @Test - public void testDockerForEcrJobStaging(){ + public void testDockerForEcrOnlyJobStaging() { + + binding.setVariable('PLATFORM', 'ECR') + + helper.registerAllowedMethod("git", [Map]) + super.testPipeline("jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile", + "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-only-ecr.jenkinsfile") + } + + @Test + public void testDockerForEcrAndDockerhubJobStaging() { + + binding.setVariable('PLATFORM', 'docker-hub + ECR') binding.setVariable('DOCKER_USERNAME ', 'docker_username') binding.setVariable('DOCKER_PASSWORD', 'docker_password') helper.registerAllowedMethod("git", [Map]) super.testPipeline("jenkins/docker-ecr/docker-build-with-ecr.jenkinsfile", - "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr.jenkinsfile") - - } + "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr-dockerhub.jenkinsfile") + } } diff --git a/tests/jenkins/TestDockerPromoteWithDockerhubOnlyJob.groovy b/tests/jenkins/TestDockerPromoteWithDockerhubOnlyJob.groovy new file mode 100644 index 0000000000..17008a7836 --- /dev/null +++ b/tests/jenkins/TestDockerPromoteWithDockerhubOnlyJob.groovy @@ -0,0 +1,34 @@ +import jenkins.tests.BuildPipelineTest +import org.junit.Before +import org.junit.Test + +class TestDockerPromoteWithDockerhubOnlyJob extends BuildPipelineTest { + + @Before + void setUp() { + String imageRepository = 'ci-runner-staging' + String imageTag = 'latest' + String accountName = 'aws_account_artifact' + String sourceImagePath = "opensearchstaging/${imageRepository}:${imageTag}" + + this.registerLibTester(new CopyContainerLibTester(sourceImagePath, + "opensearchproject/${imageRepository}:${imageTag}", + 'docker', + 'jenkins-staging-docker-prod-token')) + + super.setUp() + + binding.setVariable('IMAGE_REPOSITORY', imageRepository) + binding.setVariable('IMAGE_TAG', imageTag) + binding.setVariable('AWS_ACCOUNT_ARTIFACT', accountName) + binding.setVariable('PLATFORM', 'docker-hub') + + } + + @Test + public void testDockerForEcrJobProductionWithDockerhubOnly(){ + super.testPipeline("jenkins/docker-ecr/docker-ecr-promote.jenkinsfile", + "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-dockerhub-only.jenkinsfile") + } + +} diff --git a/tests/jenkins/TestDockerPromoteJob.groovy b/tests/jenkins/TestDockerPromoteWithEcrAndDockerhubJob.groovy similarity index 81% rename from tests/jenkins/TestDockerPromoteJob.groovy rename to tests/jenkins/TestDockerPromoteWithEcrAndDockerhubJob.groovy index 291be2f443..6f6aee0fe0 100644 --- a/tests/jenkins/TestDockerPromoteJob.groovy +++ b/tests/jenkins/TestDockerPromoteWithEcrAndDockerhubJob.groovy @@ -2,7 +2,7 @@ import jenkins.tests.BuildPipelineTest import org.junit.Before import org.junit.Test -class TestDockerPromoteJob extends BuildPipelineTest { +class TestDockerPromoteWithEcrAndDockerhubJob extends BuildPipelineTest { @Before void setUp() { @@ -21,19 +21,20 @@ class TestDockerPromoteJob extends BuildPipelineTest { "opensearchproject/${imageRepository}:${imageTag}", 'docker', 'jenkins-staging-docker-prod-token')) - + super.setUp() binding.setVariable('IMAGE_REPOSITORY', imageRepository) binding.setVariable('IMAGE_TAG', imageTag) binding.setVariable('AWS_ACCOUNT_ARTIFACT', accountName) + binding.setVariable('PLATFORM', 'docker-hub + ECR') } @Test - public void testDockerForEcrJobProduction(){ + public void testDockerForEcrAndDockerhubJobProductionWithECR(){ super.testPipeline("jenkins/docker-ecr/docker-ecr-promote.jenkinsfile", - "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote.jenkinsfile") + "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-dockerhub.jenkinsfile") } } diff --git a/tests/jenkins/TestDockerPromoteWithEcrOnlyJob.groovy b/tests/jenkins/TestDockerPromoteWithEcrOnlyJob.groovy new file mode 100644 index 0000000000..3a9d59e4a0 --- /dev/null +++ b/tests/jenkins/TestDockerPromoteWithEcrOnlyJob.groovy @@ -0,0 +1,35 @@ +import jenkins.tests.BuildPipelineTest +import org.junit.Before +import org.junit.Test + +class TestDockerPromoteWithEcrOnlyJob extends BuildPipelineTest { + + @Before + void setUp() { + String imageRepository = 'ci-runner-staging' + String imageTag = 'latest' + String accountName = 'aws_account_artifact' + String sourceImagePath = "opensearchstaging/${imageRepository}:${imageTag}" + + this.registerLibTester(new CopyContainerLibTester(sourceImagePath, + "public.ecr.aws/p5f6l6i3/${imageRepository}:${imageTag}", + 'ecr', + 'public.ecr.aws/p5f6l6i3', + accountName)) + + super.setUp() + + binding.setVariable('IMAGE_REPOSITORY', imageRepository) + binding.setVariable('IMAGE_TAG', imageTag) + binding.setVariable('AWS_ACCOUNT_ARTIFACT', accountName) + binding.setVariable('PLATFORM', 'ECR') + + } + + @Test + public void testDockerForEcrAndDockerhubJobProductionWithECR(){ + super.testPipeline("jenkins/docker-ecr/docker-ecr-promote.jenkinsfile", + "tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-only.jenkinsfile") + } + +} diff --git a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-dockerhub-only.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-dockerhub-only.jenkinsfile.txt new file mode 100644 index 0000000000..2a8125b2fd --- /dev/null +++ b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-dockerhub-only.jenkinsfile.txt @@ -0,0 +1,22 @@ + docker-build-with-ecr.run() + docker-build-with-ecr.legacySCM(groovy.lang.Closure) + docker-build-with-ecr.library({identifier=jenkins@20211123, retriever=null}) + docker-build-with-ecr.pipeline(groovy.lang.Closure) + docker-build-with-ecr.timeout({time=1, unit=HOURS}) + docker-build-with-ecr.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14, reuseNode:false, stages:[:], args:-u root -v /var/run/docker.sock:/var/run/docker.sock, alwaysPull:false, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) + docker-build-with-ecr.stage(check-params, groovy.lang.Closure) + docker-build-with-ecr.script(groovy.lang.Closure) + docker-build-with-ecr.stage(docker-build-dockerhub-staging, groovy.lang.Closure) + docker-build-with-ecr.script(groovy.lang.Closure) + docker-build-with-ecr.git({url=https://github.com/opensearch-project/opensearch-build, branch=main}) + docker-build-with-ecr.usernamePassword({credentialsId=jenkins-staging-docker-staging-credential, usernameVariable=DOCKER_USERNAME, passwordVariable=DOCKER_PASSWORD}) + docker-build-with-ecr.withCredentials([[DOCKER_USERNAME, DOCKER_PASSWORD]], groovy.lang.Closure) + docker-build-with-ecr.sh( + set -e + docker logout && docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD && eval $DOCKER_BUILD_SCRIPT_WITH_COMMANDS + ) + docker-build-with-ecr.echo(Skipping stage docker-ecr-staging) + docker-build-with-ecr.script(groovy.lang.Closure) + docker-build-with-ecr.postCleanup() + postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true}) + docker-build-with-ecr.sh(docker logout && docker image prune -f --all) diff --git a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr-dockerhub.jenkinsfile.txt similarity index 97% rename from tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr.jenkinsfile.txt rename to tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr-dockerhub.jenkinsfile.txt index 4f2a9f0de1..a57cc2b9c2 100644 --- a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr.jenkinsfile.txt +++ b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-ecr-dockerhub.jenkinsfile.txt @@ -2,7 +2,7 @@ docker-build-with-ecr.legacySCM(groovy.lang.Closure) docker-build-with-ecr.library({identifier=jenkins@20211123, retriever=null}) docker-build-with-ecr.pipeline(groovy.lang.Closure) - docker-build-with-ecr.timeout({time=3, unit=HOURS}) + docker-build-with-ecr.timeout({time=1, unit=HOURS}) docker-build-with-ecr.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14, reuseNode:false, stages:[:], args:-u root -v /var/run/docker.sock:/var/run/docker.sock, alwaysPull:false, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) docker-build-with-ecr.stage(check-params, groovy.lang.Closure) docker-build-with-ecr.script(groovy.lang.Closure) diff --git a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-only-ecr.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-only-ecr.jenkinsfile.txt new file mode 100644 index 0000000000..8c88f261cd --- /dev/null +++ b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-only-ecr.jenkinsfile.txt @@ -0,0 +1,23 @@ + docker-build-with-ecr.run() + docker-build-with-ecr.legacySCM(groovy.lang.Closure) + docker-build-with-ecr.library({identifier=jenkins@20211123, retriever=null}) + docker-build-with-ecr.pipeline(groovy.lang.Closure) + docker-build-with-ecr.timeout({time=1, unit=HOURS}) + docker-build-with-ecr.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14, reuseNode:false, stages:[:], args:-u root -v /var/run/docker.sock:/var/run/docker.sock, alwaysPull:false, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) + docker-build-with-ecr.stage(check-params, groovy.lang.Closure) + docker-build-with-ecr.script(groovy.lang.Closure) + docker-build-with-ecr.echo(Skipping stage docker-build-dockerhub-staging) + docker-build-with-ecr.stage(docker-ecr-staging, groovy.lang.Closure) + docker-build-with-ecr.script(groovy.lang.Closure) + docker-build-with-ecr.copyContainer({sourceImagePath=opensearchstaging/ci-runner-staging:latest, destinationImagePath=public.ecr.aws/m0o1u6w1/ci-runner-staging:latest, destinationType=ecr, destinationCredentialIdentifier=public.ecr.aws/m0o1u6w1, accountName=aws_account_public}) + copyContainer.sh({script=test -f /usr/local/bin/gcrane && echo '1' || echo '0' , returnStdout=true}) + copyContainer.sh(docker logout) + copyContainer.withAWS({role=Upload_ECR_Image, roleAccount=aws_account_public, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + copyContainer.sh( + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/m0o1u6w1 + gcrane cp opensearchstaging/ci-runner-staging:latest public.ecr.aws/m0o1u6w1/ci-runner-staging:latest + ) + docker-build-with-ecr.script(groovy.lang.Closure) + docker-build-with-ecr.postCleanup() + postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true}) + docker-build-with-ecr.sh(docker logout && docker image prune -f --all) diff --git a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-dockerhub.jenkinsfile.txt similarity index 98% rename from tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote.jenkinsfile.txt rename to tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-dockerhub.jenkinsfile.txt index 2729d8735b..6cf2ce0e00 100644 --- a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote.jenkinsfile.txt +++ b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-dockerhub.jenkinsfile.txt @@ -2,7 +2,7 @@ docker-ecr-promote.legacySCM(groovy.lang.Closure) docker-ecr-promote.library({identifier=jenkins@20211123, retriever=null}) docker-ecr-promote.pipeline(groovy.lang.Closure) - docker-ecr-promote.timeout({time=3, unit=HOURS}) + docker-ecr-promote.timeout({time=1, unit=HOURS}) docker-ecr-promote.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14, reuseNode:false, stages:[:], args:-u root, alwaysPull:false, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) docker-ecr-promote.stage(dockerhub-promote-to-prod, groovy.lang.Closure) docker-ecr-promote.script(groovy.lang.Closure) diff --git a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-only.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-only.jenkinsfile.txt new file mode 100644 index 0000000000..605d20c174 --- /dev/null +++ b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-ECR-only.jenkinsfile.txt @@ -0,0 +1,21 @@ + docker-ecr-promote.run() + docker-ecr-promote.legacySCM(groovy.lang.Closure) + docker-ecr-promote.library({identifier=jenkins@20211123, retriever=null}) + docker-ecr-promote.pipeline(groovy.lang.Closure) + docker-ecr-promote.timeout({time=1, unit=HOURS}) + docker-ecr-promote.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14, reuseNode:false, stages:[:], args:-u root, alwaysPull:false, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) + docker-ecr-promote.echo(Skipping stage dockerhub-promote-to-prod) + docker-ecr-promote.stage(ecr-promote-to-prod, groovy.lang.Closure) + docker-ecr-promote.script(groovy.lang.Closure) + docker-ecr-promote.copyContainer({sourceImagePath=opensearchstaging/ci-runner-staging:latest, destinationImagePath=public.ecr.aws/p5f6l6i3/ci-runner-staging:latest, destinationType=ecr, destinationCredentialIdentifier=public.ecr.aws/p5f6l6i3, accountName=aws_account_artifact}) + copyContainer.sh({script=test -f /usr/local/bin/gcrane && echo '1' || echo '0' , returnStdout=true}) + copyContainer.sh(docker logout) + copyContainer.withAWS({role=Upload_ECR_Image, roleAccount=aws_account_artifact, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) + copyContainer.sh( + aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/p5f6l6i3 + gcrane cp opensearchstaging/ci-runner-staging:latest public.ecr.aws/p5f6l6i3/ci-runner-staging:latest + ) + docker-ecr-promote.script(groovy.lang.Closure) + docker-ecr-promote.postCleanup() + postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true}) + docker-ecr-promote.sh(docker logout) diff --git a/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-dockerhub-only.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-dockerhub-only.jenkinsfile.txt new file mode 100644 index 0000000000..fb44a48157 --- /dev/null +++ b/tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-dockerhub-only.jenkinsfile.txt @@ -0,0 +1,22 @@ + docker-ecr-promote.run() + docker-ecr-promote.legacySCM(groovy.lang.Closure) + docker-ecr-promote.library({identifier=jenkins@20211123, retriever=null}) + docker-ecr-promote.pipeline(groovy.lang.Closure) + docker-ecr-promote.timeout({time=1, unit=HOURS}) + docker-ecr-promote.echo(Executing on agent [docker:[image:opensearchstaging/ci-runner:ubuntu2004-x64-docker-buildx0.6.3-qemu5.0-awscli1.22-jdk14, reuseNode:false, stages:[:], args:-u root, alwaysPull:false, containerPerStageRoot:false, label:Jenkins-Agent-al2-x64-c54xlarge-Docker-Host]]) + docker-ecr-promote.stage(dockerhub-promote-to-prod, groovy.lang.Closure) + docker-ecr-promote.script(groovy.lang.Closure) + docker-ecr-promote.copyContainer({sourceImagePath=opensearchstaging/ci-runner-staging:latest, destinationImagePath=opensearchproject/ci-runner-staging:latest, destinationType=docker, destinationCredentialIdentifier=jenkins-staging-docker-prod-token}) + copyContainer.sh({script=test -f /usr/local/bin/gcrane && echo '1' || echo '0' , returnStdout=true}) + copyContainer.sh(docker logout) + copyContainer.usernamePassword({credentialsId=jenkins-staging-docker-prod-token, usernameVariable=DOCKER_USERNAME, passwordVariable=DOCKER_PASSWORD}) + copyContainer.withCredentials([[DOCKER_USERNAME, DOCKER_PASSWORD]], groovy.lang.Closure) + copyContainer.sh( + docker login -u DOCKER_USERNAME -p DOCKER_PASSWORD + gcrane cp opensearchstaging/ci-runner-staging:latest opensearchproject/ci-runner-staging:latest + ) + docker-ecr-promote.echo(Skipping stage ecr-promote-to-prod) + docker-ecr-promote.script(groovy.lang.Closure) + docker-ecr-promote.postCleanup() + postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true}) + docker-ecr-promote.sh(docker logout)