2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Ericsson AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
16 # remove the expired items from cache
17 test -f $WORKSPACE/ci/clean_cache.sh && $WORKSPACE/ci/clean_cache.sh $CACHE_DIRECTORY
19 LATEST_ISO_PROPERTIES=$WORKSPACE/latest.iso.properties
20 if [[ "$JOB_NAME" =~ "daily" ]]; then
21 # check to see if we already have an artifact on artifacts.opnfv.org
22 # for this commit during daily builds
23 echo "Checking to see if we already built and stored Fuel ISO for this commit"
25 curl -s -o $LATEST_ISO_PROPERTIES http://$GS_URL/latest.properties 2>/dev/null
27 # get metadata of latest ISO
28 LATEST_ISO_SHA1=$(grep OPNFV_GIT_SHA1 $LATEST_ISO_PROPERTIES | cut -d'=' -f2)
29 LATEST_ISO_URL=$(grep OPNFV_ARTIFACT_URL $LATEST_ISO_PROPERTIES | cut -d'=' -f2)
35 CURRENT_SHA1=$(git rev-parse HEAD)
37 # set FORCE_BUILD to false for non-daily builds
38 FORCE_BUILD=${FORCE_BUILD:-false}
40 if [[ "$CURRENT_SHA1" == "$LATEST_ISO_SHA1" && "$FORCE_BUILD" == "false" ]]; then
41 echo "***************************************************"
42 echo " An ISO has already been built for this commit"
43 echo " $LATEST_ISO_URL"
44 echo "***************************************************"
45 # echo "Nothing new to build. Exiting."
46 # touch $WORKSPACE/.noupload
49 echo "This commit has not been built yet or forced build! Proceeding with the build."
50 /bin/rm -f $LATEST_ISO_PROPERTIES
55 echo "Starting the build of $INSTALLER_TYPE. This could take some time..."
56 echo "--------------------------------------------------------"
59 # create the cache directory if it doesn't exist
60 mkdir -p $CACHE_DIRECTORY
62 # set OPNFV_ARTIFACT_VERSION
63 if [[ "$JOB_NAME" =~ "merge" ]]; then
64 echo "Building Fuel ISO for a merged change"
65 export OPNFV_ARTIFACT_VERSION="gerrit-$GERRIT_CHANGE_NUMBER"
67 export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
70 NOCACHE_PATTERN="verify: no-cache"
71 if [[ "$JOB_NAME" =~ "verify" && "$GERRIT_CHANGE_COMMIT_MESSAGE" =~ "$NOCACHE_PATTERN" ]]; then
72 echo "The cache will not be used for this build!"
75 NOCACHE_ARG=${NOCACHE_ARG:-}
79 ./build.sh -v $OPNFV_ARTIFACT_VERSION $NOCACHE_ARG -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
81 # list the build artifacts
82 ls -al $BUILD_DIRECTORY
84 # save information regarding artifact into file
86 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
87 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
88 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
89 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
90 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
91 echo "OPNFV_BUILD_URL=$BUILD_URL"
92 ) > $WORKSPACE/opnfv.properties
95 echo "--------------------------------------------------------"