summaryrefslogtreecommitdiffstats
path: root/jjb/include-docker-push.sh
blob: 015ac745338e6fa39012b595a57baf1ca8be3c31 (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
#!/bin/bash

DOCKER_REPOSITORY="nexus3.onap.org:10003"
SEARCH="aai-service";
DATETIME_STAMP=$(date +%Y%m%dT%H%M%S);
VERSION_FILE="version.properties"

# Check for the version file
# If it exists, load the version from that file
# If not found, then use the current version as 1.1.0 for docker images
if [ -f "$VERSION_FILE" ]; then
    source $VERSION_FILE;
    VERSION=$release_version;
else
    VERSION=1.1.0;
fi


SNAPSHOT_TAG=${VERSION}-SNAPSHOT-${DATETIME_STAMP};
STAGING_TAG=${VERSION}-STAGING-${DATETIME_STAMP};

if [[ $PROJECT =~ $SEARCH ]] ; then

    REPO_PATH=$DOCKER_REPOSITORY/openecomp/ajsc-aai;

    docker tag $REPO_PATH:latest $REPO_PATH:$STAGING_TAG;
    docker tag $REPO_PATH:latest $REPO_PATH:$SNAPSHOT_TAG;

    if [ "$VERSION" == "1.0.0" ]; then
        docker tag $REPO_PATH:latest $REPO_PATH:1.0-STAGING-latest;
        docker push $REPO_PATH:1.0-STAGING-latest;
    else if [ "$VERSION" == "1.1.0" ]; then
        docker tag $REPO_PATH:latest $REPO_PATH:1.1-STAGING-latest;
        docker push $REPO_PATH:1.0-STAGING-latest;
    else
        docker push $REPO_PATH:latest;
    fi

    docker push $REPO_PATH:$STAGING_TAG;
    docker push $REPO_PATH:$SNAPSHOT_TAG;
else
    # Cut the prefix aai/ in example aai/model-loader
    DOCKER_REPO_NAME=$(echo ${PROJECT} | cut -d"/" -f2-);

    REPO_PATH=$DOCKER_REPOSITORY/openecomp/${DOCKER_REPO_NAME};

    docker tag $REPO_PATH:latest $REPO_PATH:$STAGING_TAG;
    docker tag $REPO_PATH:latest $REPO_PATH:$SNAPSHOT_TAG;

    if [ "$VERSION" == "1.0.0" ]; then
        docker tag $REPO_PATH:latest $REPO_PATH:1.0-STAGING-latest;
        docker push $REPO_PATH:1.0-STAGING-latest;
    else
        docker push $REPO_PATH:latest;
    fi

    docker push $REPO_PATH:$SNAPSHOT_TAG;
    docker push $REPO_PATH:$STAGING_TAG;
fi