diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2016-11-22 16:29:20 +0100 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2016-11-28 10:24:21 +0100 |
commit | d84b20c90908bfa4e2e544f06b422226b67e2b26 (patch) | |
tree | 7c918003f8390a2b140822b237763b7583a19b50 /jjb/opnfv/opnfv-docker.sh | |
parent | 3dd256b66f19f382eb3cdb27719af48c84e84804 (diff) |
Refactor Docker build jobs
- Remove incremental tags for stable branches
- Use "latest" or "stable" tags only
- Have a single job template for all projects
More info here: https://wiki.opnfv.org/display/INF/Docker+handling+in+CI
Change-Id: Ibce3ef2faee136f56f0eab12dfe7a93c267db854
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'jjb/opnfv/opnfv-docker.sh')
-rw-r--r-- | jjb/opnfv/opnfv-docker.sh | 52 |
1 files changed, 9 insertions, 43 deletions
diff --git a/jjb/opnfv/opnfv-docker.sh b/jjb/opnfv/opnfv-docker.sh index e637f7b32..e0fbb7564 100644 --- a/jjb/opnfv/opnfv-docker.sh +++ b/jjb/opnfv/opnfv-docker.sh @@ -20,7 +20,7 @@ echo if [[ -n $(ps -ef|grep 'docker build'|grep -v grep) ]]; then echo "There is already another build process in progress:" echo $(ps -ef|grep 'docker build'|grep -v grep) - # Abort this job since it will colide and might mess up the current one. + # Abort this job since it will collide and might mess up the current one. echo "Aborting..." exit 1 fi @@ -51,20 +51,6 @@ if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then done fi -# If we just want to update the latest_stable image -if [[ "$UPDATE_LATEST_STABLE" == "true" ]]; then - echo "Pulling $DOCKER_REPO_NAME:$STABLE_TAG ..." - docker pull $DOCKER_REPO_NAME:$STABLE_TAG - if [[ $? -ne 0 ]]; then - echo "ERROR: The image $DOCKER_REPO_NAME with tag $STABLE_TAG does not exist." - exit 1 - fi - docker tag $DOCKER_REPO_NAME:$STABLE_TAG $DOCKER_REPO_NAME:latest_stable - echo "Pushing $DOCKER_REPO_NAME:latest_stable ..." - docker push $DOCKER_REPO_NAME:latest_stable - exit 0 -fi - # cd to directory where Dockerfile is located cd $WORKSPACE/docker @@ -78,35 +64,20 @@ branch="${GIT_BRANCH##origin/}" echo "Current branch: $branch" if [[ "$branch" == "master" ]]; then - DOCKER_TAG="master" - DOCKER_BRANCH_TAG="latest" + DOCKER_TAG="latest" else - git clone https://gerrit.opnfv.org/gerrit/releng $WORKSPACE/releng - - DOCKER_TAG=$($WORKSPACE/releng/utils/calculate_version.sh -t docker \ - -n $DOCKER_REPO_NAME) - DOCKER_BRANCH_TAG="stable" - - ret_val=$? - if [[ $ret_val -ne 0 ]]; then - echo "Error retrieving the version tag." - exit 1 - fi + DOCKER_TAG="stable" fi -echo "Tag version to be build and pushed: $DOCKER_TAG" - # Start the build -echo "Building docker image: $DOCKER_REPO_NAME:$DOCKER_BRANCH_TAG" +echo "Building docker image: $DOCKER_REPO_NAME:$DOCKER_TAG" +echo "--------------------------------------------------------" +echo +cmd="docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_TAG --build-arg BRANCH=$branch ." -if [[ $DOCKER_REPO_NAME == *"functest"* ]]; then - docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_BRANCH_TAG --build-arg BRANCH=$branch . -else - docker build --no-cache -t $DOCKER_REPO_NAME:$DOCKER_BRANCH_TAG . -fi +echo ${cmd} +${cmd} -echo "Creating tag '$DOCKER_TAG'..." -docker tag $DOCKER_REPO_NAME:$DOCKER_BRANCH_TAG $DOCKER_REPO_NAME:$DOCKER_TAG # list the images echo "Available images are:" @@ -117,10 +88,5 @@ if [[ "$PUSH_IMAGE" == "true" ]]; then echo "Pushing $DOCKER_REPO_NAME:$DOCKER_TAG to the docker registry..." echo "--------------------------------------------------------" echo - # Push to the Dockerhub repository - echo "Pushing $DOCKER_REPO_NAME:$DOCKER_BRANCH_TAG ..." - docker push $DOCKER_REPO_NAME:$DOCKER_BRANCH_TAG - - echo "Pushing $DOCKER_REPO_NAME:$DOCKER_TAG ..." docker push $DOCKER_REPO_NAME:$DOCKER_TAG fi |