Last active
September 7, 2016 13:05
-
-
Save epishan/2fd33944541585cbb38a094cec58aea5 to your computer and use it in GitHub Desktop.
Revisions
-
epishan revised this gist
Sep 7, 2016 . 1 changed file with 11 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,18 +6,17 @@ println "currentJob --> ${currentJob}" println "currentBuild --> ${currentBuild}" if (branch=="") { try { println "setting BRANCH from the last build" def lastBuild = currentJob.lastSuccessfulBuild println "lastBuild -> ${lastBuild}" //branch = lastBuild.getBuildVariables().get("BRANCH"); def git_branch = lastBuild.envVars['GIT_BRANCH'] branch = git_branch.split('/',2)[1] } catch (error) { println "ERROR -> ${error}" branch="" } } println "currentBranch --> ${branch}" -
epishan created this gist
Sep 7, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ // this script will reuse GIT_BRANCH variable from the last successful job, if current BRANCH parameter is empty def branch="$BRANCH" println "currentJob --> ${currentJob}" println "currentBuild --> ${currentBuild}" if (branch=="") { try { println "setting BRANCH from the last build" def lastBuild = currentJob.lastSuccessfulBuild println "lastBuild -> ${lastBuild}" //branch = lastBuild.getBuildVariables().get("BRANCH"); def git_branch = lastBuild.envVars['GIT_BRANCH'] branch = git_branch.split('/',2)[1] } catch (error) { println "ERROR -> ${error}" branch="" } finally { } } println "currentBranch --> ${branch}" def map = [BRANCH: "${branch}"] return map