forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update new docker jobs to make ECR optional (opensearch-project#1859)
* update docker jobs with boolean ECR option Signed-off-by: Abhinav Gupta <[email protected]> * change expression Signed-off-by: Abhinav Gupta <[email protected]> * update when condition Signed-off-by: Abhinav Gupta <[email protected]> * update when condition Signed-off-by: Abhinav Gupta <[email protected]> * update description Signed-off-by: Abhinav Gupta <[email protected]> * updated job to have dropdown for ecr and dockerhub Signed-off-by: Abhinav Gupta <[email protected]> * update default Signed-off-by: Abhinav Gupta <[email protected]> * update default Signed-off-by: Abhinav Gupta <[email protected]> * updated the job timeout to be 1 hour Signed-off-by: Abhinav Gupta <[email protected]> * update regression files Signed-off-by: Abhinav Gupta <[email protected]>
- Loading branch information
1 parent
ff4a457
commit 39446d4
Showing
13 changed files
with
239 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} | ||
|
||
} |
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
34 changes: 34 additions & 0 deletions
34
tests/jenkins/TestDockerPromoteWithDockerhubOnlyJob.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,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") | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...s/jenkinsjob-regression-files/docker-ecr/docker-build-with-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,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) |
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
23 changes: 23 additions & 0 deletions
23
...jenkins/jenkinsjob-regression-files/docker-ecr/docker-build-with-only-ecr.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,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) |
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
21 changes: 21 additions & 0 deletions
21
...s/jenkinsjob-regression-files/docker-ecr/docker-ecr-promote-with-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,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) |
22 changes: 22 additions & 0 deletions
22
...insjob-regression-files/docker-ecr/docker-ecr-promote-with-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,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) |