Skip to content

Jenkins Pipeline compatibility #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

erik-am
Copy link
Contributor

@erik-am erik-am commented Apr 7, 2017

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:

  • GitVersion expects the branch name in the environment variable GIT_BRANCH while using Jenkins. This is true for the old Git plugin, but when using Jenkins pipeline, the branch name is stored in BRANCH_NAME instead.
    A workaround that people use is to add env.GIT_BRANCH = env.BRANCH_NAME in the Jenkinsfile, but this pollutes the pipeline.
  • Somehow Jenkins will add two remotes origin and origin1 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
  • Within a pull request, both the pull request number and the number of commit should be taken into account, e.g., 1.0.4-PullRequest0005.3. However, the actual result was 1.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+).

@erik-am erik-am force-pushed the feature/jenkins-pipeline-compatibility branch from 3eacd76 to cae0f62 Compare April 7, 2017 14:01
@erik-am
Copy link
Contributor Author

erik-am commented Apr 7, 2017

The build and tests pass in AppVeyor, but fail in Travis CI.
I see that's the case for other PR's as well, so I guess that's normal?

@JakeGinnivan
Copy link
Contributor

Nice work

@JakeGinnivan JakeGinnivan merged commit c2b0cbd into GitTools:master May 11, 2017
@JakeGinnivan
Copy link
Contributor

And yeah, travis is stuffed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants