Publish images to Docker Hub (#5264)

This commit enables the images publishing to Docker Hub in Drone CI. Every pull request merging will trigger this process.
This commit is contained in:
Wenkai Yin 2018-07-09 11:03:51 +08:00 committed by Yan
parent ad7a85da51
commit fd5c17bced
2 changed files with 16 additions and 1 deletions

View File

@ -50,6 +50,8 @@ pipeline:
- mail_pwd - mail_pwd
- npm_password - npm_password
- npm_username - npm_username
- docker_hub_username
- docker_hub_password
commands: commands:
- export DOMAIN=${CI_DOMAIN} - export DOMAIN=${CI_DOMAIN}
- export HOST_CONTAINER_ID=$(hostname) - export HOST_CONTAINER_ID=$(hostname)

View File

@ -115,6 +115,18 @@ function package_offline_installer {
du -ks $harbor_build_bundle | awk '{print $1 / 1024}' | { read x; echo $x MB; } du -ks $harbor_build_bundle | awk '{print $1 / 1024}' | { read x; echo $x MB; }
} }
# publish images to Docker Hub
function publishImage {
echo "Publishing images to Docker Hub..."
echo "The images on the host:"
docker images
docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
# rename the images with tag "dev" and push to Docker Hub
docker images | sed -n "s|\(vmware/[-._a-z0-9]*\)\s*\(.*$Harbor_Assets_Version\).*|docker tag \1:\2 \1:dev;docker push \1:dev|p" | bash
echo "Images are published successfully"
docker images
}
## --------------------------------------------- Run Test Case --------------------------------------------- ## --------------------------------------------- Run Test Case ---------------------------------------------
echo "--------------------------------------------------" echo "--------------------------------------------------"
echo "Running CI for $DRONE_BUILD_EVENT on $DRONE_BRANCH" echo "Running CI for $DRONE_BUILD_EVENT on $DRONE_BRANCH"
@ -187,6 +199,7 @@ if [ $upload_build == true ] && [ $rc -eq 0 ]; then
uploader $harbor_build_bundle $harbor_target_bucket uploader $harbor_build_bundle $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz $harbor_target_bucket uploader harbor-offline-installer-latest.tgz $harbor_target_bucket
upload_bundle_success=true upload_bundle_success=true
publishImage
fi fi
## --------------------------------------------- Upload Harbor Latest Build File ---------------------------------- ## --------------------------------------------- Upload Harbor Latest Build File ----------------------------------