When executing the GitVersion tool in the Jenkings pipeline, the output is different from the result when I run the GitVersion tool on my local development environment.
It seems for example the PreReleaseNumber
is not calculated correctly (is always 1) and the Branch information is not generated as it should be.
I set up an Jenkins CI pipeline and want to use sematic versioning for publishing NuGet packages of the build. This is how the Jenkinsfile
looks like:
pipeline {
// ... triggers, options, environment variables
stages {
stage ('Checkout') {
steps {
checkout scmGit(
branches: [[name: "${env.GIT_BRANCH}"]],
extensions: [
cloneOption(honorRefspec: true, noTags: false),
pruneStaleBranch(),
localBranch()
],
userRemoteConfigs: [
[
credentialsId: '<GitCredentialsId>',
url: '<GitRepositoryUrl>'
]
]
)
}
}
stage('Generate build version') {
steps {
dir('Sources') {
powershell "dotnet tool restore"
powershell "dotnet tool run dotnet-gitversion /updateprojectfiles"
}
}
}
}
}
On the Jenkins build agent the generated output looks like this:
{
"Major": 5,
"Minor": 2,
"Patch": 0,
"PreReleaseTag": "origin-develop.1",
"PreReleaseTagWithDash": "-origin-develop.1",
"PreReleaseLabel": "origin-develop",
"PreReleaseLabelWithDash": "-origin-develop",
"PreReleaseNumber": 1,
"WeightedPreReleaseNumber": 1,
"BuildMetaData": 69,
"BuildMetaDataPadded": "0069",
"FullBuildMetaData": "69.Branch.origin-develop.Sha.07338ba92656a6c5f581b212caf13981b2a20dc8",
"MajorMinorPatch": "5.2.0",
"SemVer": "5.2.0-origin-develop.1",
"LegacySemVer": "5.2.0-origin-develop1",
"LegacySemVerPadded": "5.2.0-origin-develop0001",
"AssemblySemVer": "5.2.0.0",
"AssemblySemFileVer": "5.2.0.0",
"FullSemVer": "5.2.0-origin-develop.1+69",
"InformationalVersion": "5.2.0-origin-develop.1+69.Branch.origin-develop.Sha.07338ba92656a6c5f581b212caf13981b2a20dc8",
"BranchName": "origin/develop",
"EscapedBranchName": "origin-develop",
"Sha": "07338ba92656a6c5f581b212caf13981b2a20dc8",
"ShortSha": "07338ba",
"NuGetVersionV2": "5.2.0-origin-develop0001",
"NuGetVersion": "5.2.0-origin-develop0001",
"NuGetPreReleaseTagV2": "origin-develop0001",
"NuGetPreReleaseTag": "origin-develop0001",
"VersionSourceSha": "d010aa4d359890610133e6d88ee3241c9d4a0caa",
"CommitsSinceVersionSource": 69,
"CommitsSinceVersionSourcePadded": "0069",
"UncommittedChanges": 4,
"CommitDate": "2024-06-16"
}
Same repository branch on local development system (this is, what I want in Jenkins pipeline):
{
"Major": 5,
"Minor": 2,
"Patch": 0,
"PreReleaseTag": "alpha.69",
"PreReleaseTagWithDash": "-alpha.69",
"PreReleaseLabel": "alpha",
"PreReleaseLabelWithDash": "-alpha",
"PreReleaseNumber": 69,
"WeightedPreReleaseNumber": 69,
"BuildMetaData": null,
"BuildMetaDataPadded": "",
"FullBuildMetaData": "Branch.develop.Sha.07338ba92656a6c5f581b212caf13981b2a20dc8",
"MajorMinorPatch": "5.2.0",
"SemVer": "5.2.0-alpha.69",
"LegacySemVer": "5.2.0-alpha69",
"LegacySemVerPadded": "5.2.0-alpha0069",
"AssemblySemVer": "5.2.0.0",
"AssemblySemFileVer": "5.2.0.0",
"FullSemVer": "5.2.0-alpha.69",
"InformationalVersion": "5.2.0-alpha.69+Branch.develop.Sha.07338ba92656a6c5f581b212caf13981b2a20dc8",
"BranchName": "develop",
"EscapedBranchName": "develop",
"Sha": "07338ba92656a6c5f581b212caf13981b2a20dc8",
"ShortSha": "07338ba",
"NuGetVersionV2": "5.2.0-alpha0069",
"NuGetVersion": "5.2.0-alpha0069",
"NuGetPreReleaseTagV2": "alpha0069",
"NuGetPreReleaseTag": "alpha0069",
"VersionSourceSha": "d010aa4d359890610133e6d88ee3241c9d4a0caa",
"CommitsSinceVersionSource": 69,
"CommitsSinceVersionSourcePadded": "0069",
"UncommittedChanges": 0,
"CommitDate": "2024-06-16"
}
user25595877 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.