Skip to content

Commit

Permalink
Update docker related copy lib to new version (#3800)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon authored Jul 24, 2023
1 parent b6d67aa commit e0e7d72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions jenkins/docker/docker-copy.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = library(identifier: 'jenkins@4.2.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@5.2.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -76,7 +76,7 @@ pipeline {
always {
script {
postCleanup()
sh "docker logout ${DESTINATION_IMAGE_REGISTRY} && docker image prune -f --all"
sh "docker logout && docker logout public.ecr.aws && docker image prune -f --all"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/TestDockerCopy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TestDockerCopy extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('4.2.0')
.defaultVersion('5.2.0')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docker-copy.run()
docker-copy.modernSCM({$class=GitSCMSource, remote=https://github.com/opensearch-project/opensearch-build-libraries.git})
docker-copy.library({identifier=jenkins@4.2.0, retriever=null})
docker-copy.library({identifier=jenkins@5.2.0, retriever=null})
docker-copy.pipeline(groovy.lang.Closure)
docker-copy.timeout({time=30})
docker-copy.echo(Executing on agent [label:none])
Expand All @@ -9,11 +9,14 @@
docker-copy.stage(Copy Image to ECR/DockerHub, groovy.lang.Closure)
docker-copy.script(groovy.lang.Closure)
docker-copy.copyContainer({allTags=false, sourceImage=ci-runner:testtag, sourceRegistry=opensearchstaging, destinationImage=ci-runner:testtag2, destinationRegistry=public.ecr.aws/opensearchstaging})
copyContainer.usernamePassword({credentialsId=jenkins-staging-dockerhub-credential, usernameVariable=DOCKER_USERNAME, passwordVariable=DOCKER_PASSWORD})
copyContainer.withCredentials([[DOCKER_USERNAME, DOCKER_PASSWORD]], groovy.lang.Closure)
copyContainer.sh(set +x && echo DOCKER_PASSWORD | docker login --username DOCKER_USERNAME --password-stdin)
copyContainer.sh(set +x && aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opensearchstaging)
copyContainer.echo(Copying single image tag from opensearchstaging/ci-runner:testtag to public.ecr.aws/opensearchstaging/ci-runner:testtag2)
copyContainer.sh(set -x && crane cp opensearchstaging/ci-runner:testtag public.ecr.aws/opensearchstaging/ci-runner:testtag2)
copyContainer.sh(set +x && docker logout && docker logout public.ecr.aws/opensearchstaging)
copyContainer.sh(set +x && docker logout && docker logout public.ecr.aws)
docker-copy.script(groovy.lang.Closure)
docker-copy.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
docker-copy.sh(docker logout public.ecr.aws/opensearchstaging && docker image prune -f --all)
docker-copy.sh(docker logout && docker logout public.ecr.aws && docker image prune -f --all)

0 comments on commit e0e7d72

Please sign in to comment.