-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Abhinav Gupta <[email protected]>
- Loading branch information
1 parent
6dffa4f
commit 6c8817b
Showing
8 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/jenkins/TestDockerPromoteWithLatestTagDockerHubJob.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import jenkins.tests.BuildPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class TestDockerPromoteWithLatestTagDockerHubJob extends BuildPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
String imageRepository = 'ci-runner-staging' | ||
String imageTag = '1.3.0' | ||
String accountName = 'aws_account_artifact' | ||
String sourceImagePath = "opensearchstaging/${imageRepository}:${imageTag}" | ||
|
||
this.registerLibTester(new CopyContainerLibTester(sourceImagePath, | ||
"opensearchproject/${imageRepository}:${imageTag}", | ||
'docker', | ||
'jenkins-staging-docker-prod-token')) | ||
|
||
this.registerLibTester(new CopyContainerLibTester(sourceImagePath, | ||
"opensearchproject/${imageRepository}:latest", | ||
'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') | ||
binding.setVariable('TAG_LATEST', 'true') | ||
|
||
} | ||
|
||
@Test | ||
public void testDockerForEcrJobProductionWithDockerhubOnly(){ | ||
super.testPipeline("jenkins/docker-ecr/docker-ecr-promote.jenkinsfile", | ||
"tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-latestTag-dockerhub-only.jenkinsfile") | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
tests/jenkins/TestDockerPromoteWithLatestTagEcrOnlyJob.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import jenkins.tests.BuildPipelineTest | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class TestDockerPromoteWithLatestTagEcrOnlyJob extends BuildPipelineTest { | ||
|
||
@Before | ||
void setUp() { | ||
String imageRepository = 'ci-runner-staging' | ||
String imageTag = '1.3.0' | ||
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)) | ||
|
||
this.registerLibTester(new CopyContainerLibTester(sourceImagePath, | ||
"public.ecr.aws/p5f6l6i3/${imageRepository}:latest", | ||
'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') | ||
binding.setVariable('TAG_LATEST', 'true') | ||
|
||
} | ||
|
||
@Test | ||
public void testDockerForEcrAndDockerhubJobProductionWithECR(){ | ||
super.testPipeline("jenkins/docker-ecr/docker-ecr-promote.jenkinsfile", | ||
"tests/jenkins/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-latestTag-ECR-only.jenkinsfile") | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...ob-regression-files/docker-ecr/docker-ecr-promote-with-latestTag-ECR-only.jenkinsfile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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:1.3.0, destinationImagePath=public.ecr.aws/p5f6l6i3/ci-runner-staging:1.3.0, 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:1.3.0 public.ecr.aws/p5f6l6i3/ci-runner-staging:1.3.0 | ||
) | ||
docker-ecr-promote.copyContainer({sourceImagePath=opensearchstaging/ci-runner-staging:1.3.0, 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:1.3.0 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) |
31 changes: 31 additions & 0 deletions
31
...ression-files/docker-ecr/docker-ecr-promote-with-latestTag-dockerhub-only.jenkinsfile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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:1.3.0, destinationImagePath=opensearchproject/ci-runner-staging:1.3.0, 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:1.3.0 opensearchproject/ci-runner-staging:1.3.0 | ||
) | ||
docker-ecr-promote.copyContainer({sourceImagePath=opensearchstaging/ci-runner-staging:1.3.0, 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:1.3.0 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) |