aboutsummaryrefslogtreecommitdiffstats
path: root/script-dmaapbc-docker-build.sh
blob: 3d7647c8d62135f60e4ed2fad0f3601d276142e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Create a debian package and push to remote repo
#
#
# build the docker image. tag and then push to the remote repo
#

# !!! make sure the yaml file include docker-login as a builder before calling
# this script

if [ "$#" != "1" ]; then
    phase="verify"
else
    phase="$1"
    case $phase in
        verify|merge|release)
            echo "Running $phase job"
        ;;
        *)
            echo "Unknown phase $phase"
            exit 1
    esac
fi


IMAGE='openecomp/dcae_dmaapbc'
VERSION=$(xpath -e "//project/version/text()" "pom.xml")
EXT=$(echo "$VERSION" | rev | cut -s -f1 -d'-' | rev)
if [ -z "$EXT" ]; then
    VERSION=$(echo "${VERSION}-STAGING")
fi
TIMESTAMP=$(date +%C%y%m%dT%H%M%S)
echo $VERSION
echo $TIMESTAMP
TAG="${VERSION}-${TIMESTAMP}"
LFQI="${IMAGE}:${TAG}"
BUILD_PATH="${WORKSPACE}"

# build a docker image
docker build --rm -f "${WORKSPACE}"/Dockerfile -t "${LFQI}" "${BUILD_PATH}"

if [ "$phase" == "verify" ]; then
    exit
fi

#
# push the image
#
# io registry  DOCKER_REPOSITORIES="nexus3.openecomp.org:10001 \
# release registry                   nexus3.openecomp.org:10002 \
# snapshot registry                   nexus3.openecomp.org:10003"
REPO='nexus3.openecomp.org:10003'
RFQI="${REPO}/${LFQI}"
echo "$LFQI"
echo "$RFQI"
docker tag "${LFQI}" "${RFQI}"
docker push "${RFQI}"

TAG="latest"
LFQI="${IMAGE}:${TAG}"
RFQI2="${REPO}/${LFQI}"
echo "$LFQI"
echo "$RFQI2"
docker tag "${RFQI}" "${RFQI2}"
docker push "${RFQI2}"