diff options
author | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-08-08 06:02:41 -0700 |
---|---|---|
committer | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-08-08 07:29:57 -0700 |
commit | 27553f737c5d9717d5ef96b38cda3bfa52e9ccc1 (patch) | |
tree | 1eedbfc98c70da82e4e207df4ff5562fa78230f7 /build-dockers.sh | |
parent | fd43ca256b21606c64d1463a3cd024fbf73b4a54 (diff) |
Fix the docker build image workflowv1.2.0
Fixed the Docker build image workflow.
Added seperate tagging for SNAPSHOT-latest and STAGING-latest
There are two docker jobs currently. One produces SNAPSHOT images
and other produces STAGING images. SNAPSHOT images are build from
nexus2 maven snapshots artifacts where as STAGING images are built
from nexus2 maven releases artifacts.
Removed libxml2-utils dependency from docker build image script.
Since the dedicated docker node might be shared by multiple jobs,
apt-get install inside the script might cause conflict and cause
failure of the docker jenkins jobs. Moved the dependency to be part
of the jenkins infrastructure node itself.
Change-Id: I122974c984b1b0ece98bbd5a783d7923504abf3e
Issue-ID: OPTFRA-301
Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
Diffstat (limited to 'build-dockers.sh')
-rwxr-xr-x | build-dockers.sh | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/build-dockers.sh b/build-dockers.sh index 0b02b32..b606e03 100755 --- a/build-dockers.sh +++ b/build-dockers.sh @@ -19,6 +19,7 @@ VERSION=$release_version SNAPSHOT=$snapshot_version STAGING=${release_version}-STAGING TIMESTAMP=$(date +"%Y%m%dT%H%M%S")Z +REPO="" if [ $HTTP_PROXY ]; then BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" @@ -33,7 +34,6 @@ function log_ts() { # Log message with timestamp function get_artifact_version() { log_ts Get Maven Artifact version from pom.xml - sudo apt-get install libxml2-utils MVN_ARTIFACT_VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell conductor/pom.xml | grep content | sed 's/.*content=//'` log_ts Maven artifact version for HAS is $MVN_ARTIFACT_VERSION if [[ "$MVN_ARTIFACT_VERSION" =~ SNAPSHOT ]]; then @@ -53,25 +53,40 @@ function build_image() { log_ts ... Built } -function tag_image() { - log_ts Tagging images: ${IMAGE_NAME}:\{$SNAPSHOT-${TIMESTAMP},$STAGING-${TIMESTAMP},latest\} +function push_image() { + if [[ "$REPO" == snapshots ]]; then + push_snapshot_image + else + push_staging_image + fi +} + +function push_snapshot_image(){ + log_ts Tagging images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\} docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP} - docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} - docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:latest + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${SNAPSHOT}-latest log_ts ... Tagged images -} -function push_image(){ - log_ts Pushing images: ${IMAGE_NAME}:\{$SNAPSHOT-${TIMESTAMP},$STAGING-${TIMESTAMP},latest\} + log_ts Pushing images: ${IMAGE_NAME}:\{${SNAPSHOT}-${TIMESTAMP},${SNAPSHOT}-latest\} docker push ${IMAGE_NAME}:${SNAPSHOT}-${TIMESTAMP} + docker push ${IMAGE_NAME}:${SNAPSHOT}-latest + log_ts ... Pushed images +} + +function push_staging_image(){ + log_ts Tagging images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} + docker tag ${IMAGE_NAME}:latest ${IMAGE_NAME}:${STAGING}-latest + log_ts ... Tagged images + + log_ts Pushing images: ${IMAGE_NAME}:\{${STAGING}-${TIMESTAMP},${STAGING}-latest\} docker push ${IMAGE_NAME}:${STAGING}-${TIMESTAMP} - docker push ${IMAGE_NAME}:latest + docker push ${IMAGE_NAME}:${STAGING}-latest log_ts ... Pushed images } ( get_artifact_version build_image - tag_image push_image -)
\ No newline at end of file +) |