Created
November 27, 2019 19:47
-
-
Save kenrachynski/f8e5aedf55da07f552bcadd0b90d0f7d to your computer and use it in GitHub Desktop.
Jenkinsfile processing multiple environments
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 characters
| pipeline { | |
| agent any | |
| environment { | |
| COMMITDATE = "" | |
| } | |
| stages { | |
| stage('setup') { | |
| steps { | |
| script { | |
| COMMITDATE = sh(returnStdout: true, script: "git show -s --format=%ci ${GIT_COMMIT}") | |
| } | |
| echo "${COMMITDATE}" | |
| sh script: 'git rev-parse --abbrev-ref HEAD' | |
| echo env.GIT_BRANCH | |
| } | |
| } | |
| stage('1') { | |
| when { branch 'staging' } | |
| steps { echo 'This stage only runs on the staging branch' } | |
| } | |
| stage('2') { | |
| when { branch 'staging' } | |
| steps { echo 'This stage only runs on the staging branch' } | |
| } | |
| stage('3') { | |
| when { branch 'master' } | |
| steps { echo 'This stage only runs on the master branch' } | |
| } | |
| stage('4') { | |
| when { branch 'staging'} | |
| steps { echo 'This stage only runs on the staging branch' } | |
| } | |
| } | |
| } |
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 characters
| Branch indexing | |
| > git rev-parse --is-inside-work-tree # timeout=10 | |
| Setting origin to git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| > git config remote.origin.url git@git-yyc.iceedge.local:users/krachynski/jenkinsfile # timeout=10 | |
| Fetching origin... | |
| Fetching upstream changes from origin | |
| > git --version # timeout=10 | |
| > git config --get remote.origin.url # timeout=10 | |
| using GIT_SSH to set credentials Used with git-yyc | |
| > git fetch --tags --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| Seen branch in repository origin/master | |
| Seen branch in repository origin/staging | |
| Seen 2 remote branches | |
| Obtained Jenkinsfile from 94b4f41dc956cad6baf00840f3cffd43d7b20a57 | |
| Running in Durability level: MAX_SURVIVABILITY | |
| [Pipeline] Start of Pipeline | |
| [Pipeline] node | |
| Running on Jenkins in /var/jenkins_home/workspace/jenkinsfile-mb_master | |
| [Pipeline] { | |
| [Pipeline] stage | |
| [Pipeline] { (Declarative: Checkout SCM) | |
| [Pipeline] checkout | |
| using credential git-yyc-key | |
| Cloning the remote Git repository | |
| Cloning with configured refspecs honoured and without tags | |
| Cloning repository git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| > git init /var/jenkins_home/workspace/jenkinsfile-mb_master # timeout=10 | |
| Fetching upstream changes from git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| > git --version # timeout=10 | |
| using GIT_SSH to set credentials Used with git-yyc | |
| > git fetch --no-tags --progress -- git@git-yyc.iceedge.local:users/krachynski/jenkinsfile +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| > git config remote.origin.url git@git-yyc.iceedge.local:users/krachynski/jenkinsfile # timeout=10 | |
| > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| > git config remote.origin.url git@git-yyc.iceedge.local:users/krachynski/jenkinsfile # timeout=10 | |
| Fetching without tags | |
| Fetching upstream changes from git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| using GIT_SSH to set credentials Used with git-yyc | |
| > git fetch --no-tags --progress -- git@git-yyc.iceedge.local:users/krachynski/jenkinsfile +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| Checking out Revision 94b4f41dc956cad6baf00840f3cffd43d7b20a57 (master) | |
| > git config core.sparsecheckout # timeout=10 | |
| > git checkout -f 94b4f41dc956cad6baf00840f3cffd43d7b20a57 # timeout=10 | |
| Commit message: "Show branch name if available" | |
| First time build. Skipping changelog. | |
| > git --version # timeout=10 | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] withEnv | |
| [Pipeline] { | |
| [Pipeline] withEnv | |
| [Pipeline] { | |
| [Pipeline] stage | |
| [Pipeline] { (setup) | |
| [Pipeline] script | |
| [Pipeline] { | |
| [Pipeline] sh | |
| + git show -s --format=%ci 94b4f41dc956cad6baf00840f3cffd43d7b20a57 | |
| [Pipeline] } | |
| [Pipeline] // script | |
| [Pipeline] echo | |
| 2019-11-25 16:56:04 -0700 | |
| [Pipeline] sh | |
| + git rev-parse --abbrev-ref HEAD | |
| HEAD | |
| [Pipeline] echo | |
| master | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (1) | |
| Stage "1" skipped due to when conditional | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (2) | |
| Stage "2" skipped due to when conditional | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (3) | |
| [Pipeline] echo | |
| This stage only runs on the master branch | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] } | |
| [Pipeline] // withEnv | |
| [Pipeline] } | |
| [Pipeline] // withEnv | |
| [Pipeline] } | |
| [Pipeline] // node | |
| [Pipeline] End of Pipeline | |
| Finished: SUCCESS |
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 characters
| Branch indexing | |
| > git rev-parse --is-inside-work-tree # timeout=10 | |
| Setting origin to git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| > git config remote.origin.url git@git-yyc.iceedge.local:users/krachynski/jenkinsfile # timeout=10 | |
| Fetching origin... | |
| Fetching upstream changes from origin | |
| > git --version # timeout=10 | |
| > git config --get remote.origin.url # timeout=10 | |
| using GIT_SSH to set credentials Used with git-yyc | |
| > git fetch --tags --progress -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| Seen branch in repository origin/master | |
| Seen branch in repository origin/staging | |
| Seen 2 remote branches | |
| Obtained Jenkinsfile from e54bb312cfa156668d007482a5bae2b2d42b2126 | |
| Running in Durability level: MAX_SURVIVABILITY | |
| [Pipeline] Start of Pipeline | |
| [Pipeline] node | |
| Running on Jenkins in /var/jenkins_home/workspace/jenkinsfile-mb_staging | |
| [Pipeline] { | |
| [Pipeline] stage | |
| [Pipeline] { (Declarative: Checkout SCM) | |
| [Pipeline] checkout | |
| using credential git-yyc-key | |
| Cloning the remote Git repository | |
| Cloning with configured refspecs honoured and without tags | |
| Cloning repository git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| > git init /var/jenkins_home/workspace/jenkinsfile-mb_staging # timeout=10 | |
| Fetching upstream changes from git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| > git --version # timeout=10 | |
| using GIT_SSH to set credentials Used with git-yyc | |
| > git fetch --no-tags --progress -- git@git-yyc.iceedge.local:users/krachynski/jenkinsfile +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| > git config remote.origin.url git@git-yyc.iceedge.local:users/krachynski/jenkinsfile # timeout=10 | |
| > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| > git config remote.origin.url git@git-yyc.iceedge.local:users/krachynski/jenkinsfile # timeout=10 | |
| Fetching without tags | |
| Fetching upstream changes from git@git-yyc.iceedge.local:users/krachynski/jenkinsfile | |
| using GIT_SSH to set credentials Used with git-yyc | |
| > git fetch --no-tags --progress -- git@git-yyc.iceedge.local:users/krachynski/jenkinsfile +refs/heads/*:refs/remotes/origin/* # timeout=10 | |
| Checking out Revision e54bb312cfa156668d007482a5bae2b2d42b2126 (staging) | |
| > git config core.sparsecheckout # timeout=10 | |
| > git checkout -f e54bb312cfa156668d007482a5bae2b2d42b2126 # timeout=10 | |
| Commit message: "Add another stage for staging" | |
| First time build. Skipping changelog. | |
| > git --version # timeout=10 | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] withEnv | |
| [Pipeline] { | |
| [Pipeline] withEnv | |
| [Pipeline] { | |
| [Pipeline] stage | |
| [Pipeline] { (setup) | |
| [Pipeline] script | |
| [Pipeline] { | |
| [Pipeline] sh | |
| + git show -s --format=%ci e54bb312cfa156668d007482a5bae2b2d42b2126 | |
| [Pipeline] } | |
| [Pipeline] // script | |
| [Pipeline] echo | |
| 2019-11-25 17:01:14 -0700 | |
| [Pipeline] sh | |
| + git rev-parse --abbrev-ref HEAD | |
| HEAD | |
| [Pipeline] echo | |
| staging | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (1) | |
| [Pipeline] echo | |
| This stage only runs on the staging branch | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (2) | |
| [Pipeline] echo | |
| This stage only runs on the staging branch | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (3) | |
| Stage "3" skipped due to when conditional | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] stage | |
| [Pipeline] { (4) | |
| [Pipeline] echo | |
| This stage only runs on the staging branch | |
| [Pipeline] } | |
| [Pipeline] // stage | |
| [Pipeline] } | |
| [Pipeline] // withEnv | |
| [Pipeline] } | |
| [Pipeline] // withEnv | |
| [Pipeline] } | |
| [Pipeline] // node | |
| [Pipeline] End of Pipeline | |
| Finished: SUCCESS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment