3 # ================================================================================
4 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=========================================================
21 echo "--> docker-ts-tag-override.sh"
23 # Get project version from pom.xml
24 version=`xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" $DOCKER_ROOT/pom.xml`
25 echo "INFO: version from pom file $version"
27 # Some pom has -SNAPSHOT or -STAGING under pom version, remove all text
28 version="${version//[^0-9.]/}"
30 # Get build TS for specifying in the tag
31 timestamp=$(date +%C%y%m%dT%H%M%SZ)
33 # Following the https://wiki.onap.org/display/DW/Independent+Versioning+and+Release+Process
34 # IndependentVersioningandReleaseProcess-StandardizedDockerTagging
35 # ONAP Tag requirement : {imagename}:{semver}-SNAPSHOT-{timestamp}Z (from CIMAN-132)
37 if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
38 tag="${version}-SNAPSHOT-${timestamp}"
40 # Default to latest tag with TS if not conforming to semantic versioning
41 echo "WARN: version not complaint to sem-ver; tag defaulted to latest"
43 tag="${version}-${timestamp}"
46 echo "INFO: docker tag is $tag"
48 # Write DOCKER_IMAGE_TAG information to a file so it can be
49 # injected into the environment for following steps
50 echo "DOCKER_IMAGE_TAG=$tag" >> "$WORKSPACE/env_docker_inject.txt"