3 echo '============== STARTING SCRIPT TO BUILD DOCKER IMAGES ================='
4 DOCKER_REPOSITORY=nexus3.onap.org:10003
5 MVN_VERSION=$(cat target/version)
6 MVN_MAJMIN_VERSION=$(cut -f 1,2 -d . target/version)
7 TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
9 echo $DOCKER_REPOSITORY
11 echo $MVN_MAJMIN_VERSION
14 if [[ -z $MVN_VERSION ]]
16 echo "MVN_VERSION is empty"
20 if [[ -z $MVN_MAJMIN_VERSION ]]
22 echo "MVN_MAJMIN_VERSION is empty"
26 if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
28 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-SNAPSHOT"
30 MVN_MAJMIN_VERSION="${MVN_MAJMIN_VERSION}-STAGING"
33 echo $MVN_MAJMIN_VERSION
35 cp policy-pe/* target/policy-pe/
36 cp policy-drools/* target/policy-drools/
38 for image in policy-os policy-nexus policy-db policy-base policy-drools policy-pe ; do
39 echo "Building $image"
40 mkdir -p target/$image
41 cp $image/* target/$image
44 # This is the local latest tagged image. The Dockerfile's need this to build images
46 TAGS="--tag onap/policy/${image}:latest"
48 # This is the nexus repo prepended for latest tagged image.
50 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:latest"
52 # This has the nexus repo prepended and only major/minor version with latest
54 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_MAJMIN_VERSION}-latest"
56 # This has the nexus repo prepended and major/minor/patch version with timestamp
58 TAGS="${TAGS} --tag ${DOCKER_REPOSITORY}/onap/policy/${image}:${MVN_VERSION}-STAGING-${TIMESTAMP}"
62 docker build --quiet $TAGS target/$image
66 echo "Docker build failed"
74 for image in policy-nexus policy-db policy-drools policy-pe; do
77 docker push ${DOCKER_REPOSITORY}/onap/policy/$image:latest
81 echo "Docker push failed"
86 docker push ${DOCKER_REPOSITORY}/onap/policy/$image:${MVN_MAJMIN_VERSION}-latest
90 echo "Docker push failed"
94 docker push ${DOCKER_REPOSITORY}/onap/policy/$image:${MVN_VERSION}-STAGING-${TIMESTAMP}
98 echo "Docker push failed"