Jenkins Pipeline compatibility #1201
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GitVersion includes support for Jenkins as a build system, but this only supports traditional Jenkins jobs, not the new way of using Jenkins Pipeline.
Currently, you can find all kinds of workarounds on the web to make GitVersion play nicely with Jenkins Pipeline-as-code. This pull request aims to fix it within GitVersion so that one doesn't need workarounds in his pipeline.
Current problems:
GIT_BRANCH
while using Jenkins. This is true for the old Git plugin, but when using Jenkins pipeline, the branch name is stored inBRANCH_NAME
instead.A workaround that people use is to add
env.GIT_BRANCH = env.BRANCH_NAME
in the Jenkinsfile, but this pollutes the pipeline.origin
andorigin1
when executing the Pipeline.GitTools will therefore fail with the error "2 remote(s) have been detected"
A workaround to remove the duplicate origin has been posted at http://stackoverflow.com/questions/39475135/gitversion-in-a-jenkins-multibranch-pipeline-job
1.0.4-PullRequest0005.3
. However, the actual result was1.0.4-PullRequest.3
, missing the PR number and therefore leading to duplicates. This can be fixed by changing the default tag number pattern from[/-](?<number>\d+)[/-]
to[/-](?<number>\d+)
.