summaryrefslogtreecommitdiffstats
path: root/docker/build_image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docker/build_image.sh')
-rwxr-xr-xdocker/build_image.sh36
1 files changed, 26 insertions, 10 deletions
diff --git a/docker/build_image.sh b/docker/build_image.sh
index 6930c5c..3d9d823 100755
--- a/docker/build_image.sh
+++ b/docker/build_image.sh
@@ -28,6 +28,7 @@ VERSION=$release_version
SNAPSHOT=$snapshot_version
STAGING=${release_version}-STAGING
TIMESTAMP=$(date +"%Y%m%dT%H%M%S")Z
+REPO=""
BUILD_ARGS="--no-cache"
if [ $HTTP_PROXY ]; then
@@ -43,7 +44,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 pom.xml | grep content | sed 's/.*content=//'`
log_ts Maven artifact version for OSDF is $MVN_ARTIFACT_VERSION
if [[ "$MVN_ARTIFACT_VERSION" =~ SNAPSHOT ]]; then
@@ -63,19 +63,36 @@ 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
}
@@ -84,6 +101,5 @@ function push_image(){
# Switch to docker build directory
cd $(dirname $0)
build_image
- tag_image
push_image
)