We have following branch setup:
master and release/1.0 branches.
master, tagged with 1.0 and producing 1.0.1, 1.0.2 versions.
release/1.0 branch created from master, and master then tagged with 2.0.
The expectation is that both branches produce "stable" versions so there're no prerelease tags.
When running GitVersion on these branches, the release branch produces version 1.0.3 and master branch produces version 2.0.1. So far so good, this is what we expected.
Now one of our colleagues created a new feature branch from the release branch, which they then merge master into afterwards. The feature branch was then merged back into the release branch with a pull request. After the completing the pull request, GitVersion now gives 2.0.X on the release branch, instead of 1.0.X.
To try and fix the issue, we tagged the release branch with 1.0.4. However, with every new commit into release branch, the problem comes back. This forces use to manually tag every commit into release branch to give us our desired version number.
We're using GitVersion 4.0.0-beta0014 in mainline mode.
The config looks like:
mode: mainline
assembly-versioning-scheme: MajorMinorPatch
continuous-delivery-fallback-tag: ''
commit-message-incrementing: Disabled
branches:
master:
tag: ''
feature:
regex: features?[/-]
tag: unstable.{BranchName}
release:
tag: ''
is-mainline: true
bugfix:
regex: bugfix[/-]
tag: unstable.{BranchName}
ignore:
sha: []
Anybody any idea how to get out of this?
Lubos
I think you're looking for the "prevent merge branch increment option" - there's some documentation on it here:
https://gitversion.net/docs/configuration#prevent-increment-of-merged-branch-version
basically you just set it to true in your gitversion.yml like below:
mode: mainline
assembly-versioning-scheme: MajorMinorPatch
continuous-delivery-fallback-tag: ''
commit-message-incrementing: Disabled
branches:
master:
tag: ''
feature:
regex: features?[/-]
tag: unstable.{BranchName}
release:
tag: ''
is-mainline: true
bugfix:
regex: bugfix[/-]
tag: unstable.{BranchName}
ignore:
sha: []
prevent-increment-of-merged-branch-version: true
Related
resources:
builds:
- build: Spaceworkz
type: Jenkins
connection: MyJenkinsServer
source: SpaceworkzProj # name of the jenkins source project
trigger: true
Then, I use downloadBuild step.
How can I later in the pipeline get the version number of this build? It will be "latest" but I need the version number.
I can't see anything in doc.
I had made a commit in the GitLab branch, then merged it into the main branch, but the .gitlab-ci.yml pipeline is not updating the last committed code into the production server.
Note: Pipeline is working, but committed changes are not visible.
Depend on your version of GitLab, it could be an older bug.
For instance, gitlab-org/gitlab-runner issue 4587 "GitlabRunner does not check out the latest commit but the previous one"
In your gitlab-ci.yml, check what
Workaround:
have same problem, but if use checkout & pull - everything ok
git checkout -f $CI_COMMIT_REF_NAME && git pull
As in, for instance:
script:
- echo $CI_COMMIT_REF_NAME
- git checkout $CI_COMMIT_REF_NAME
- git pull
I had the same issue.
Try turning off the cache in your pipeline and see once
- cache:
We would like to use GitVersion for your git repo and the following is our branching strategy.
Master - development branch which will build and deploy every pull request merged. 1.0.0-alpha.x
Release/v1.x.x - release branch which will be deployed end of sprint. 1.0.0-beta.x
Hotfix - branched from master and cherry pick to release branch.
Currently the version on master branch is working fine as 1.0.0-alpha.36 but when i created release branch (release/v1.0.0) it created a version 1.0.0-beta.0 instead 1.0.0-beta.36. What configuration i can set to achieve above.
GitVersion.yml
next-version: 1.0.2
mode: ContinuousDeployment
continuous-delivery-fallback-tag: ''
branches:
master:
mode: ContinuousDeployment
tag: 'alpha'
pull-request:
mode: ContinuousDeployment
tag: 'pr'
increment: None
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
regex: (pull|pull\-requests|pr|[0-9]+)[/-]
tracks-release-branches: false
is-release-branch: false
release:
regex: release?[/]
mode: ContinuousDeployment
tag: 'beta'
is-release-branch: true
ignore:
sha: []
merge-message-formats: {}
Please advise ?
Need to trigger CI build job when a PR is merged to master (only when change is inside ./rel/* path) but not have CI build triggered when the Pull Request (PR) is created. So I have the trigger config as below.
trigger:
branches:
include:
- master
paths:
include:
- ./rel/*
pr: none # will disable PR builds (but not CI builds)
But it fails to trigger CI build when pr: none is added. If pr: none is removed, The Job is getting triggered for both PR and a merge to master. I would only need the job/CI build to run on a merge to master.
The paths filter in the YAML is looking at paths in your repository file structure, not the branch path. To have it only trigger on rel branch, replace the master under the include branches with ./rel/* (or the correct value).
We have a more defined pipeline that runs unit tests on PR and then only packages for release on merge into the master branch. We do this by having our trigger set to the master branch and using conditions for each stage in the multi-stage pipeline. Check those out as well.
Solved! This works now.
trigger:
branches:
include:
- master
paths:
include:
- ./rel/*
pr: none # will disable PR builds (but not CI builds)
Also you can configure / override using the classic azure devops UI from Triggers.
Ref : https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=classic#ci-triggers
So, I am able to deploy a code by using a specific git tag and the build is picking the accurate commit as per that git tag. That is perfectly working, however, the same build is always picking only the latest commit for Jenkinsfile. Is there any way I can make Jenkins pick the Jenkinsfile from a specific commit as well?
Here's my checkout method:
$class: 'GitSCM',
branches: [[name: "refs/tags/${env.tag}"]],
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])