diff --git a/jenkins.groovy b/jenkins.groovy index 7d73a57d..a943c44b 100644 --- a/jenkins.groovy +++ b/jenkins.groovy @@ -2,10 +2,17 @@ import jobs.generation.Utilities; import jobs.generation.InternalUtilities; def project = GithubProject -def branch = GithubBranchName +def projectName = "pxt-calliope" [true, false].each { isPR -> - def newJobName = InternalUtilities.getFullJobName(project, "Default", isPR) + def newJobName = projectName + + if (isPR) { + newJobName += "_PR" + } else { + newJobName += "_Push" + } + def newJob = job(newJobName) { steps { shell("chmod +x ./jenkins.sh") @@ -15,14 +22,14 @@ def branch = GithubBranchName if (!isPR) { wrappers { credentialsBinding { - string('PXT_ACCESS_TOKEN', 'pxt_access_token') - string('PXT_RELEASE_REPO', 'pxt_release_repo_calliope') + string("PXT_ACCESS_TOKEN", "pxt_access_token") + string("PXT_RELEASE_REPO", "pxt_release_repo_calliope") } } } } - Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020') + Utilities.setMachineAffinity(newJob, "Ubuntu", "20161020") InternalUtilities.standardJobSetup(newJob, project, isPR, "*/*") if (isPR) { diff --git a/jenkins.sh b/jenkins.sh index 2e8e964b..bef5cb23 100644 --- a/jenkins.sh +++ b/jenkins.sh @@ -13,6 +13,7 @@ echo isPR: $1 originRegex="^origin/.*" branchRegex="^origin/\K.*(?=$)" +releaseBranchRegex = "^(master|v\d+)$" if [[ "$GIT_BRANCH" =~ $originRegex ]]; then branchName=$(echo ${GIT_BRANCH} | grep -oP $branchRegex) @@ -27,9 +28,9 @@ if [ "$1" == "false" ]; then echo Setting TRAVIS_PULL_REQUEST to false export TRAVIS_PULL_REQUEST=false - if [ $TRAVIS_BRANCH == "master" ]; then + if [[ "$TRAVIS_BRANCH" =~ $releaseBranchRegex ]]; then if [[ -z $PXT_RELEASE_REPO ]]; then - echo Cannot find release repo; skipping tag checks + echo Cannot find release repo\; skipping tag checks else gitTag=$(git describe --tags --exact-match 2> /dev/null) builtTag=$(git ls-remote --tags $PXT_RELEASE_REPO | grep -o "refs/tags/$gitTag$") @@ -38,7 +39,7 @@ if [ "$1" == "false" ]; then echo Built tag: $builtTag if [[ ! -z $gitTag && -z $builtTag ]]; then - echo Built tag not found; building tag + echo Built tag not found\; building tag echo Setting TRAVIS_BRANCH to $gitTag export TRAVIS_BRANCH=$gitTag echo Setting TRAVIS_TAG to $gitTag