|
| 1 | +# TODO generalise this for the non adoptium build farm case |
| 2 | +function checkArgs() { |
| 3 | + if [ "$1" -lt 1 ]; then |
| 4 | + echo Usage: "$0" '[jdk8u|jdk11u|jdk17u|jdk19u|...]' |
| 5 | + echo "Skara Repo supplied should match a repository in https://github.com/openjdk/" |
| 6 | + echo "For example, to mirror https://github.com/openjdk/jdk17u" |
| 7 | + echo "e.g. $0 jdk17u" |
| 8 | + exit 1 |
| 9 | + fi |
| 10 | +} |
| 11 | + |
| 12 | +function cloneGitHubRepo() { |
| 13 | + cd "$WORKSPACE" || exit 1 |
| 14 | + GITHUB_REPO=$1 # https://github.com/adoptium/adoptium/jdk17u.git |
| 15 | + if [ ! -d "$JDKVERSION" ] ; then |
| 16 | + echo "First time clone repo $GITHUB_REPO" |
| 17 | + git clone -q "$GITHUB_REPO" || exit 1 |
| 18 | + else |
| 19 | + cd "$JDKVERSION" && git clean -fd && git fetch --all --tags |
| 20 | + fi |
| 21 | +} |
| 22 | + |
| 23 | +function readExpectedGATag() { |
| 24 | + source ${SCRIPT_DIR}/releasePlan.cfg |
| 25 | + jdkVersion=$1 # e.g jdk17u |
| 26 | + gaTagVariable="${jdkVersion}GA" # set gaTagVariable=jdk17uGA match releasePlan.cfg |
| 27 | + expectedTag=${!gaTagVariable} # get value, e.g: expectedTag=jdk-17.0.6 |
| 28 | + echo ${expectedTag} |
| 29 | +} |
| 30 | + |
| 31 | +# this function is not in use, due to agent does not have "jq" to parse json payload |
| 32 | +function queryGHAPI(){ |
| 33 | + repo=$1 # adoptium/jdk8u, openjdk/jdk8u |
| 34 | + tag=$2 # jdk8u362-b05_adopt, jdk8u362-ga |
| 35 | + exist="$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/${repo}/git/refs/tags/${tag}")" |
| 36 | + if [ $exist == "200" ]; then |
| 37 | + echo "Found tag: ${tag} in ${repo}" |
| 38 | + else |
| 39 | + echo "Cannot find tag: ${tag} in ${repo}" |
| 40 | + fi |
| 41 | + echo ${exist} |
| 42 | +} |
| 43 | + |
| 44 | +# to check if the same _adopt scmReference tag has been used to trigger a release pipeline in the past |
| 45 | +# if yes, wont trigger; if not, do the first time trigger |
| 46 | +function checkPrevious() { |
| 47 | + if [ -f ${WORKSPACE}/tracking ]; then # already have tracking from previous |
| 48 | + local scmRef=$1 # _adopt scmReference tag we have found |
| 49 | + local trackerTag="$(cut -d '=' -f 2 ${WORKSPACE}/tracking)" # previousSCM=jdk-17.0.5+8_adopt |
| 50 | + |
| 51 | + if [[ "${scmRef}" == "${trackerTag}" ]]; then |
| 52 | + echo "Release tag ${trackerTag} has triggered a release pipeline build already in the current release" |
| 53 | + echo "Will not continue job" |
| 54 | + exit 0 |
| 55 | + fi |
| 56 | + fi |
| 57 | +} |
0 commit comments