GitVersion does not ignore commits before on DevOps - devops
I've got a repo with multiple solutions on in.
I created a pipeline for a specific one and linked to a specific gitversion.yml file to calculate version numbers by specific commit messages. I added the ignore-commits-before tag to force version numbers to reset from 0.1.0.
This works fine in local with gitversion (v. 5.8.1) installed.
However versioning from devops (GitVersion.Tool\5.3.7) pipeline does not give same results and seems is unable to ignore previous commits.
Here is the gitversion.yml file
mode: Mainline
major-version-bump-message: '\+saa:\s?(breaking|major)'
minor-version-bump-message: '\+saa:\s?(feature|minor)'
patch-version-bump-message: '\+saa:\s?(fix|patch)'
commit-message-incrementing: Enabled
branches:
master:
tag: ci
increment: None
pull-request:
increment: None
ignore:
commits-before: 2021-11-20T14:00:00
sha:
- 0f016fd7b149c285a78c37ef7291bd75836231c8
merge-message-formats: {}
Calling gitversion from local it ignores commits before date and the output is
gitversion /config .\customer-saa\GitVersion.yml
> "SemVer": "0.1.450-saa-51815-versioning.5",
Called from DevOps the output is
\_tool\GitVersion.Tool\5.3.7\x64\dotnet-gitversion.exe C:/agent/_work/160/s /output json /output buildserver /config C:\agent\_work\160\s\customer-saa\GitVersion.yml
> "SemVer":"1.2.182-saa-51815-versioning.5",
And here'is a the log (simplified)
2021-11-21T19:40:35.6433364Z ##[section]Starting: Calculating SemVer
2021-11-21T19:40:35.6603918Z ==============================================================================
2021-11-21T19:40:35.6604166Z Task : Execute GitVersion Task
2021-11-21T19:40:35.6604421Z Description : Easy Semantic Versioning (http://semver.org) for projects using Git
2021-11-21T19:40:35.6604637Z Version : 0.9.11
2021-11-21T19:40:35.6604799Z Author : GitTools Contributors
2021-11-21T19:40:35.6605058Z Help : See the [documentation](https://gitversion.net/docs/) for help
2021-11-21T19:40:35.6605316Z ==============================================================================
2021-11-21T19:40:36.0855947Z Command: dotnet-gitversion C:/agent/_work/160/s /output json /output buildserver /config C:\agent\_work\160\s\customer-saa\GitVersion.yml
2021-11-21T19:40:36.0878401Z [command]C:\agent\_work\_tool\GitVersion.Tool\5.3.7\x64\dotnet-gitversion.exe C:/agent/_work/160/s /output json /output buildserver /config C:\agent\_work\160\s\customer-saa\GitVersion.yml
2021-11-21T19:40:39.2658808Z INFO [11/21/21 20:40:36:83] Working directory: C:/agent/_work/160/s
2021-11-21T19:40:39.2659551Z INFO [11/21/21 20:40:36:92] Branch from build environment: refs/heads/saa/51815-versioning
2021-11-21T19:40:39.2659960Z INFO [11/21/21 20:40:36:92] Project root is: C:\agent\_work\160\s\
2021-11-21T19:40:39.2660650Z INFO [11/21/21 20:40:36:92] DotGit directory is: C:\agent\_work\160\s\.git
2021-11-21T19:40:39.2661300Z INFO [11/21/21 20:40:36:92] Begin: Normalizing git directory for branch 'refs/heads/saa/51815-versioning'
2021-11-21T19:40:39.2661841Z INFO [11/21/21 20:40:36:95] One remote found (origin -> 'https://xxxxx').
2021-11-21T19:40:39.2662445Z INFO [11/21/21 20:40:36:95] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2021-11-21T19:40:39.2663022Z INFO [11/21/21 20:40:36:96] Updating local branch refs/heads/saa/51815-versioning to point at df0be162c0ec4a813fd35124c1696e9fcd3b15ac
2021-11-21T19:40:39.2663560Z INFO [11/21/21 20:40:37:33] Creating local branch from remote tracking 'refs/remotes/origin/df0be162c0ec4a813fd35124c1696e9fcd3b15ac'.
2021-11-21T19:40:39.2667521Z INFO [11/21/21 20:40:37:37] Updating local ref 'refs/heads/master' to point at cc53ce41a20abc1952d3c12d83c9ad26d8237f7f.
2021-11-21T19:40:39.2667954Z INFO [11/21/21 20:40:37:38] Skipping update of 'refs/remotes/origin/ocq/upload-senza-resize' as it already matches the remote ref.
2021-11-21T19:40:39.2668375Z INFO [11/21/21 20:40:37:38] Skipping update of 'refs/remotes/origin/release/ali/1.0' as it already matches the remote ref.
2021-11-21T19:40:39.2668804Z INFO [11/21/21 20:40:37:39] Skipping update of 'refs/remotes/origin/release/int/1.2' as it already matches the remote ref.
2021-11-21T19:40:39.2669232Z INFO [11/21/21 20:40:37:39] Updating local ref 'refs/heads/release/int/1.3' to point at acce83180ecfde7304c1f488d6fb2fdae538dc7e.
2021-11-21T19:40:39.2669649Z INFO [11/21/21 20:40:37:40] Skipping update of 'refs/remotes/origin/release/ocq/1.5' as it already matches the remote ref.
2021-11-21T19:40:39.2670074Z INFO [11/21/21 20:40:37:41] Skipping update of 'refs/remotes/origin/release/ocq/1.6' as it already matches the remote ref.
2021-11-21T19:40:39.2671873Z INFO [11/21/21 20:40:37:41] Skipping update of 'refs/remotes/origin/release/ver/1.4.0' as it already matches the remote ref.
2021-11-21T19:40:39.2672294Z INFO [11/21/21 20:40:37:42] Creating local branch from remote tracking 'refs/remotes/origin/saa/51811-feature-toggle'.
2021-11-21T19:40:39.2672719Z INFO [11/21/21 20:40:37:44] Skipping update of 'refs/remotes/origin/ver/28320-selenium-test' as it already matches the remote ref.
2021-11-21T19:40:39.2673357Z INFO [11/21/21 20:40:37:44] HEAD points at branch 'refs/heads/saa/51815-versioning'.
2021-11-21T19:40:39.2673753Z INFO [11/21/21 20:40:37:45] End: Normalizing git directory for branch 'refs/heads/saa/51815-versioning' (Took: 528.27ms)
2021-11-21T19:40:39.2674228Z INFO [11/21/21 20:40:37:47] Begin: Loading version variables from disk cache
2021-11-21T19:40:39.2674627Z INFO [11/21/21 20:40:37:47] Cache file C:\agent\_work\160\s\.git\gitversion_cache\B117CA14696791C9927D1ABF850C2C808BFB27E3.yml not found.
2021-11-21T19:40:39.2675058Z INFO [11/21/21 20:40:37:47] End: Loading version variables from disk cache (Took: 1.28ms)
2021-11-21T19:40:39.2675383Z INFO [11/21/21 20:40:37:71] Using latest commit on specified branch
2021-11-21T19:40:39.2675747Z INFO [11/21/21 20:40:37:72] No branch configuration found for branch saa/51815-versioning, falling back to default configuration
2021-11-21T19:40:39.2676130Z INFO [11/21/21 20:40:37:73] Begin: Attempting to inherit branch configuration from parent branch
2021-11-21T19:40:39.2676481Z INFO [11/21/21 20:40:37:74] Begin: Finding branch source of 'saa/51815-versioning'
2021-11-21T19:40:39.2676840Z INFO [11/21/21 20:40:37:76] Begin: Finding merge base between 'saa/51815-versioning' and 'master'.
2021-11-21T19:40:39.2677193Z INFO [11/21/21 20:40:37:76] Found merge base of 0f016fd7b149c285a78c37ef7291bd75836231c8
2021-11-21T19:40:39.2677581Z INFO [11/21/21 20:40:37:77] Merge base of saa/51815-versioning' and 'master is 0f016fd7b149c285a78c37ef7291bd75836231c8
2021-11-21T19:40:39.2678050Z INFO [11/21/21 20:40:37:77] End: Finding merge base between 'saa/51815-versioning' and 'master'. (Took: 9.67ms)
[...]
2021-11-21T19:40:39.2700277Z INFO [11/21/21 20:40:37:82] Begin: Finding merge base between 'saa/51815-versioning' and 'origin/release/ver/1.4.0'.
2021-11-21T19:40:39.2700672Z INFO [11/21/21 20:40:37:82] Found merge base of 991045280c88b449e6f0d0354e0bdaba72885e08
2021-11-21T19:40:39.2701074Z INFO [11/21/21 20:40:37:82] Merge base of saa/51815-versioning' and 'origin/release/ver/1.4.0 is 991045280c88b449e6f0d0354e0bdaba72885e08
2021-11-21T19:40:39.2701538Z INFO [11/21/21 20:40:37:82] End: Finding merge base between 'saa/51815-versioning' and 'origin/release/ver/1.4.0'. (Took: 2.29ms)
2021-11-21T19:40:39.2701947Z INFO [11/21/21 20:40:37:83] Multiple source branches have been found, picking the first one (master).
2021-11-21T19:40:39.2702261Z This may result in incorrect commit counting.
2021-11-21T19:40:39.2702455Z Options were:
2021-11-21T19:40:39.2702924Z master, origin/master, release/int/1.3, release/ocq/1.6, origin/release/int/1.3, origin/release/ocq/1.6, release/int/1.2, origin/release/int/1.2, release/ver/1.4.0, origin/release/ver/1.4.0, release/ocq/1.5, origin/release/ocq/1.5, release/ali/1.0, origin/release/ali/1.0
2021-11-21T19:40:39.2703743Z INFO [11/21/21 20:40:37:83] End: Finding branch source of 'saa/51815-versioning' (Took: 86.78ms)
2021-11-21T19:40:39.2704255Z INFO [11/21/21 20:40:37:83] Begin: Getting branches containing the commit '0f016fd7b149c285a78c37ef7291bd75836231c8'.
2021-11-21T19:40:39.2704625Z INFO [11/21/21 20:40:37:83] Trying to find direct branches.
2021-11-21T19:40:39.2704957Z INFO [11/21/21 20:40:37:83] No direct branches found, searching through all branches.
2021-11-21T19:40:39.2705394Z INFO [11/21/21 20:40:37:83] Searching for commits reachable from 'master'.
2021-11-21T19:40:39.2705724Z INFO [11/21/21 20:40:37:85] The branch 'master' has a matching commit.
2021-11-21T19:40:39.2706047Z INFO [11/21/21 20:40:37:85] Searching for commits reachable from 'release/ali/1.0'.
2021-11-21T19:40:39.2706394Z INFO [11/21/21 20:40:37:87] The branch 'release/ali/1.0' has no matching commits.
2021-11-21T19:40:39.2706783Z INFO [11/21/21 20:40:37:87] Searching for commits reachable from 'release/int/1.2'.
2021-11-21T19:40:39.2707122Z INFO [11/21/21 20:40:37:89] The branch 'release/int/1.2' has no matching commits.
[...]
2021-11-21T19:40:39.2729304Z INFO [11/21/21 20:40:38:67] End: Getting branches containing the commit 'df0be162c0ec4a813fd35124c1696e9fcd3b15ac'. (Took: 422.50ms)
2021-11-21T19:40:39.2729743Z INFO [11/21/21 20:40:38:67] Found possible parent branches: master, origin/master
2021-11-21T19:40:39.2730234Z WARN [11/21/21 20:40:38:67] Failed to inherit Increment branch configuration, ended up with: master, origin/master
2021-11-21T19:40:39.2730569Z Falling back to master branch config
2021-11-21T19:40:39.2730911Z INFO [11/21/21 20:40:38:67] End: Attempting to inherit branch configuration from parent branch (Took: 942.53ms)
2021-11-21T19:40:39.2731338Z INFO [11/21/21 20:40:38:68] Running against branch: saa/51815-versioning (df0be162c0ec4a813fd35124c1696e9fcd3b15ac)
2021-11-21T19:40:39.2731695Z INFO [11/21/21 20:40:38:68] Begin: Calculating base versions
2021-11-21T19:40:39.2732762Z INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2734357Z INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2734867Z INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2735347Z INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2735835Z INFO [11/21/21 20:40:38:90] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2736315Z INFO [11/21/21 20:40:38:90] Merge message 'Merge branch 'release/ver/1.2.2'': 1.2.2 with commit count source f2f314a5e87be073a2682d1204c16454bf68be16
2021-11-21T19:40:39.2736807Z INFO [11/21/21 20:40:38:90] Merge message 'Merge branch 'release/int/1.1'': 1.1.0 with commit count source 015e42e4b0ff151a71355b8a3442de7ac94e53a1
2021-11-21T19:40:39.2737369Z INFO [11/21/21 20:40:38:90] Merge message 'Merge branch 'release/ver/1.2.1'': 1.2.1 with commit count source c205b37fa014df520ab16f9eb7393c13469c0f0c
2021-11-21T19:40:39.2737862Z INFO [11/21/21 20:40:38:91] Merge message 'Merge branch 'release/ver/1.2'': 1.2.0 with commit count source c564d5141df7616b29fadfcc3805c7ac32df8af6
2021-11-21T19:40:39.2738387Z INFO [11/21/21 20:40:38:91] Merge message 'Merge branch 'release/ver/1.1'': 1.1.0 with commit count source c09ee0b84ff269c9b6020e4da608fc727475522d
2021-11-21T19:40:39.2738920Z INFO [11/21/21 20:40:38:96] Found multiple base versions which will produce the same SemVer (1.2.2), taking oldest source for commit counting (Merge message 'Merge branch 'release/ver/1.2.2'')
2021-11-21T19:40:39.2739481Z INFO [11/21/21 20:40:38:96] Base version used: Merge message 'Merge branch 'release/ver/1.2.2'': 1.2.2 with commit count source f2f314a5e87be073a2682d1204c16454bf68be16
2021-11-21T19:40:39.2740020Z INFO [11/21/21 20:40:38:96] End: Calculating base versions (Took: 277.68ms)
2021-11-21T19:40:39.2740542Z INFO [11/21/21 20:40:38:96] Begin: Using mainline development mode to calculate current version
2021-11-21T19:40:39.2740894Z INFO [11/21/21 20:40:38:97] Found possible mainline branches: master
2021-11-21T19:40:39.2741202Z INFO [11/21/21 20:40:39:00] Mainline for current branch is master
2021-11-21T19:40:39.2741576Z INFO [11/21/21 20:40:39:00] Found branch merge point; choosing 0f016fd7b149c285a78c37ef7291bd75836231c8 as effective mainline tip
2021-11-21T19:40:39.2741996Z INFO [11/21/21 20:40:39:00] Current branch (saa/51815-versioning) was branch from 0f016fd7b149c285a78c37ef7291bd75836231c8
2021-11-21T19:40:39.2742434Z INFO [11/21/21 20:40:39:05] Direct commit on master 8ece20f67ac67d39d7f3c8cae72c534aa2e1203f incremented base versions None, now 1.2.2
2021-11-21T19:40:39.2742889Z INFO [11/21/21 20:40:39:05] Direct commit on master 640408c70b6055b3bee3b2a3a29e683ded747a3e incremented base versions None, now 1.2.2
2021-11-21T19:40:39.2744939Z INFO [11/21/21 20:40:39:05] Merge commit 9b49a0e3410dbefe443851bc2d862f09cab635c3 incremented base versions Patch, now 1.2.3
[...]
2021-11-21T19:40:39.2919007Z INFO [11/21/21 20:40:39:14] Direct commit on master 0f016fd7b149c285a78c37ef7291bd75836231c8 incremented base versions None, now 1.2.181
2021-11-21T19:40:39.2919470Z INFO [11/21/21 20:40:39:14] 5 commits found between 0f016fd7b149c285a78c37ef7291bd75836231c8 and df0be162c0ec4a813fd35124c1696e9fcd3b15ac
2021-11-21T19:40:39.2919860Z INFO [11/21/21 20:40:39:14] Performing Patch increment for current branch
2021-11-21T19:40:39.2920239Z INFO [11/21/21 20:40:39:14] End: Using mainline development mode to calculate current version (Took: 178.24ms)
2021-11-21T19:40:39.2920616Z INFO [11/21/21 20:40:39:14] Using branch name to calculate version tag
2021-11-21T19:40:39.2920957Z INFO [11/21/21 20:40:39:14] Begin: Getting version tags from branch 'refs/heads/saa/51815-versioning'.
2021-11-21T19:40:39.2921374Z INFO [11/21/21 20:40:39:17] End: Getting version tags from branch 'refs/heads/saa/51815-versioning'. (Took: 33.34ms)
2021-11-21T19:40:39.2921726Z INFO [11/21/21 20:40:39:18] Begin: Creating dictionary
2021-11-21T19:40:39.2922022Z INFO [11/21/21 20:40:39:18] End: Creating dictionary (Took: 3.64ms)
2021-11-21T19:40:39.2922497Z INFO [11/21/21 20:40:39:19] Begin: Storing version variables to cache file C:\agent\_work\160\s\.git\gitversion_cache\B117CA14696791C9927D1ABF850C2C808BFB27E3.yml
2021-11-21T19:40:39.2923179Z INFO [11/21/21 20:40:39:22] End: Storing version variables to cache file C:\agent\_work\160\s\.git\gitversion_cache\B117CA14696791C9927D1ABF850C2C808BFB27E3.yml (Took: 35.32ms)
2021-11-21T19:40:39.2923624Z Executing GenerateSetVersionMessage for 'AzurePipelines'.
2021-11-21T19:40:39.3262981Z Executing GenerateBuildLogOutput for 'AzurePipelines'.
2021-11-21T19:40:39.3292597Z {
2021-11-21T19:40:39.3292783Z "Major":1,
2021-11-21T19:40:39.3292942Z "Minor":2,
2021-11-21T19:40:39.3293118Z "Patch":182,
[...]
2021-11-21T19:40:39.3367618Z }
2021-11-21T19:40:39.3368004Z INFO [11/21/21 20:40:39:24] Done writing
2021-11-21T19:40:39.3411803Z ##[section]Async Command Start: Update Build Number
2021-11-21T19:40:39.6529458Z Update build number to 1.2.182-saa-51815-versioning.5 for build 14300
2021-11-21T19:40:39.6529816Z ##[section]Async Command End: Update Build Number
2021-11-21T19:40:39.6531031Z ##[section]Finishing: Calculating SemVer
Thanks for any help
Related
What's causing my Multibranch Pipeline to fail its scan?
I'm trying to set up a Multibranch pipeline in Jenkins with Bitbucket as the SCM. When I try to "Scan Multibranch Pipeline Now" this is the resulting console log. > git --version # 'git version 2.36.0.windows.1' using GIT_SSH to set credentials > C:/Program Files/Git/cmd/git.exe ls-remote -h -- ssh://git(repo name here).git # timeout=10 Fetching upstream changes from origin > C:/Program Files/Git/cmd/git.exe config --get remote.origin.url # timeout=10 using GIT_SSH to set credentials > C:/Program Files/Git/cmd/git.exe fetch --tags --force --progress --prune -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: [Mon Jun 27 11:02:32 PDT 2022] Could not fetch branches from source 3387233e-6185-46fa-a65c-0d4072f28149 [Mon Jun 27 11:02:32 PDT 2022] Finished branch indexing. Indexing took 7.8 sec FATAL: Failed to recompute children of MultiBranch Test hudson.plugins.git.GitException: Command "C:/Program Files/Git/cmd/git.exe fetch --tags --force --progress --prune -- origin +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Repository not found The requested repository does not exist, or you do not have permission to access it. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:618) at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:602) at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:588) at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:394) at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:350) at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:588) at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:641) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:166) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:442) Finished: FAILURE Originally, the multibranch was able to scan the repo and find the branches with Jenkinsfiles, but now that no longer works. In the first multibranch test which scanned and created pipelines for branches, when I try to build those branches it fails the build with the same error as above "repository not found". I have a successful single Pipeline working for the same repository, specifically the develop branch. It is able to build on commits and pull the jenkinsfile from the repo, so it doesnt seem there is an access issue, but that is what the Multibranch pipeline is running into. --------UPDATE----------- Randomly, the scan worked. We are not sure what/if any changes prompted the sudden correct performance.
Why does this "complicated" git clone/checkout cause gitversion to fail?
I have the following pipeline syntax code in a Jenkinsfile to clone a git repo: checkout([$class: 'GitSCM', branches: [[name: "${branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: false, recursiveSubmodules: true, reference: '', trackingSubmodules: false], [$class: 'LocalBranch', localBranch: ""], [$class: 'RelativeTargetDirectory', relativeTargetDir: relative_dir]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: cred_id, url: git_url]]]) Following is the output of one instance of this Jenkins job, which reveals the git commands used to clone a repo: > git init /home/user/workspace/CICD/PRJ/repo/PRJ/repo/121/src # timeout=10 Fetching upstream changes from ssh://git#bitbucket.company.com:7999/PRJ/repo.git > git --version # timeout=10 using GIT_SSH to set credentials user - ssh username with private key. > git fetch --tags --progress -- ssh://git#bitbucket.company.com:7999/PRJ/repo.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url ssh://git#bitbucket.company.com:7999/PRJ/repo.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url ssh://git#bitbucket.company.com:7999/PRJ/repo.git # timeout=10 Fetching upstream changes from ssh://git#bitbucket.company.com:7999/PRJ/repo.git using GIT_SSH to set credentials user - ssh username with private key. > git fetch --tags --progress -- ssh://git#bitbucket.company.com:7999/PRJ/repo.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse refs/remotes/origin/feature/hcf^{commit} # timeout=10 > git rev-parse refs/remotes/origin/refs/heads/feature/hcf^{commit} # timeout=10 Checking out Revision 37b9492373951ab0b4c70fa64a3320be58133e0e (refs/remotes/origin/feature/hcf) > git config core.sparsecheckout # timeout=10 > git checkout -f 37b9492373951ab0b4c70fa64a3320be58133e0e # timeout=10 > git branch -a -v --no-abbrev # timeout=10 > git checkout -b feature/hcf 37b9492373951ab0b4c70fa64a3320be58133e0e # timeout=10 Commit message: "Uncomment set_fault" > git rev-list --no-walk 59ce67929be6c901975596db509de7a72b3c557a # timeout=10 This same Jenkinsfile automatically applies git tags using gitversion like so: docker run -u $(id -u ${USER}):$(id -g ${USER}) --rm -v "$(pwd):/repo" artifactory.company.com/gittools/gitversion:5.7.1 /repo The above methods of git cloning and using gitversion to generate new git tags has been working fine for several months without incident. Problem: Today, gitversion failed unexpectedly when this Jenkins job was run to build a git branch that I cannot see anything unique about (versus the many successfully-built branches). The error, below, seems to indicate an inability to identify development or release branches, which are dev and master, respectively, in our case. + docker run -u 1172002866:1172000513 --rm -v /home/user/workspace/CICD/PRJ/repo/PRJ/repo/121/src:/repo artifactory.company.com/gittools/gitversion:5.7.1 /repo INFO [01/26/22 23:30:14:02] Working directory: /repo INFO [01/26/22 23:30:14:26] Project root is: /repo/ INFO [01/26/22 23:30:14:26] DotGit directory is: /repo/.git INFO [01/26/22 23:30:14:59] Begin: Loading version variables from disk cache INFO [01/26/22 23:30:14:59] Cache file /repo/.git/gitversion_cache/AF7963E4F79300A465EFC56DBA14B2B679307C08.yml not found. INFO [01/26/22 23:30:14:59] End: Loading version variables from disk cache (Took: 1.50ms) INFO [01/26/22 23:30:14:61] Using latest commit on specified branch INFO [01/26/22 23:30:14:62] Begin: Attempting to inherit branch configuration from parent branch INFO [01/26/22 23:30:14:65] Begin: Finding branch source of 'feature/hcf' INFO [01/26/22 23:30:14:66] End: Finding branch source of 'feature/hcf' (Took: 15.87ms) INFO [01/26/22 23:30:14:67] Begin: Getting branches containing the commit '37b9492'. INFO [01/26/22 23:30:14:67] Trying to find direct branches. INFO [01/26/22 23:30:14:67] No direct branches found, searching through all branches. INFO [01/26/22 23:30:14:67] Searching for commits reachable from 'origin/dev'. INFO [01/26/22 23:30:14:69] The branch 'origin/dev' has no matching commits. INFO [01/26/22 23:30:14:69] Searching for commits reachable from 'origin/master'. INFO [01/26/22 23:30:14:70] The branch 'origin/master' has no matching commits. INFO [01/26/22 23:30:14:70] Searching for commits reachable from 'origin/release-npm2'. INFO [01/26/22 23:30:14:70] The branch 'origin/release-npm2' has no matching commits. INFO [01/26/22 23:30:14:70] Searching for commits reachable from 'origin/release-npm3'. INFO [01/26/22 23:30:14:71] The branch 'origin/release-npm3' has no matching commits. INFO [01/26/22 23:30:14:71] Searching for commits reachable from 'origin/release-5944.0'. INFO [01/26/22 23:30:14:72] The branch 'origin/release-5944.0' has no matching commits. INFO [01/26/22 23:30:14:72] Searching for commits reachable from 'origin/release-5944.1'. INFO [01/26/22 23:30:14:73] The branch 'origin/release-5944.1' has no matching commits. INFO [01/26/22 23:30:14:73] End: Getting branches containing the commit '37b9492'. (Took: 63.52ms) INFO [01/26/22 23:30:14:73] Found possible parent branches: INFO [01/26/22 23:30:14:74] End: Attempting to inherit branch configuration from parent branch (Took: 116.47ms) ERROR [01/26/22 23:30:14:82] An unexpected error occurred: System.InvalidOperationException: Gitversion could not determine which branch to treat as the development branch (default is 'develop') nor releaseable branch (default is 'main' or 'master'), either locally or remotely. Ensure the local clone and checkout match the requirements or considering using 'GitVersion Dynamic Repositories' at GitVersion.Configuration.BranchConfigurationCalculator.InheritBranchConfiguration(IBranch targetBranch, BranchConfig branchConfiguration, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 137 at GitVersion.Configuration.BranchConfigurationCalculator.GetBranchConfiguration(IBranch targetBranch, ICommit currentCommit, Config configuration, IList`1 excludedInheritBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Configuration\BranchConfigurationCalculator.cs:line 47 at GitVersion.GitVersionContextFactory.Create(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionContextFactory.cs:line 40 at GitVersion.GitVersionCoreModule.<>c__DisplayClass0_0.<RegisterTypes>b__1() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\GitVersionCoreModule.cs:line 38 at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy`1.CreateValue() at System.Lazy`1.get_Value() at GitVersion.VersionCalculation.NextVersionCalculator.get_context() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 17 at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 32 at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 52 at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 70 INFO [01/26/22 23:30:14:82] Attempting to show the current git graph (please include in issue): INFO [01/26/22 23:30:14:82] Showing max of 100 commits INFO [01/26/22 23:30:14:93] * 37b9492 3 minutes ago (HEAD -> feature/hcf, origin/feature/hcf) What I have tried: When I manually clone the repo and check out the branch using the above git commands, I can reproduce the gitversion failure. When I "simplify" my git clone and branch checkout to just: $ git clone ssh://git#bitbucket.company.com:7999/PRJ/repo.git $ git checkout feature/hcf $ docker run -u $(id -u ${USER}):$(id -g ${USER}) --rm -v "$(pwd):/repo" artifactory.company.com/gittools/gitversion:5.7.1 /repo ...then gitversion succeeds and returns an expected value. Questions: Can the Jenkinsfile checkout() statement be modified so that it is functionally identical to the "simple" git clone and git checkout statements? There is obviously some salient difference between the two "methods" of cloning from git and checking out branches that is relevant to gitversion. If possible, I would prefer a solution that uses the Jenkins pipeline checkout() function over a shell script invocation like sh(script:"git clone...") -- but perhaps an experienced answerer can convince me that that preference isn't justified. Can someone explain how I can determine what is "unique" about this particular git repo or branch? With other repos/branches, the above checkout() statement in our Jenkinsfile continues to work simpatico with the subsequent gitversion invocation. So it would seem there is something unique about this one failing case that I don't know how to determine.
I don't use Jenkins myself, but it looks like the develop branch is missing from its clone of the repository, which may indicate that Jenkins is doing a sparse or shallow clone. As stated in GitVersion's requirements, it needs a full clone of the repository in order to do its calculations. The reason your git clone && git checkout statements work is because, by default, Git performs a full clone of the repository. What you need to do is instruct Jenkins to do an unshallow clone of the repository. GitVersion's Jenkins documentation lists a number of things you can and should do to have GitVersion work properly: Advanced clone behaviors Enable Fetch tags Enable Honor refspec on intial clone Check out to matching local branch Prune stale remote-tracking branches Specify ref specs Ref Spec: +refs/heads/*:refs/remotes/#{remote}/* With the above Jenkins settings tuned correctly, it should work.
Jenkins - Couldn't find any revision to build
I have been using Jenkins for a few days, and before: I used the GITEA plugin Now that I have switched my projects to GitBucket, I would like to use the "Build by Webhook" Feature. I followed many tutorials, and now : i'm stuck on a simple/big problem. In advance, I'm sorry to have to blur the sensitive links, I know it can be annoying. Here is the full error : using credential 10 Wiping out workspace first. Contributing variables: Cloning the remote Git repository Cloning repository https://MY_GITBUCKET/git/MY_USERNAME/MY_PROJECT > git init /Jenkins/workspace/GitBUcket # timeout=10 Fetching upstream changes from https://MY_GITBUCKET/git/MY_USERNAME/MY_PROJECT > git --version # timeout=10 > git --version # 'git version 2.20.1' using GIT_ASKPASS to set credentials Utilisateur GitBucket Perso > git fetch --tags --force --progress -- https://MY_GITBUCKET/git/MY_USERNAME/MY_PROJECT +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url https://MY_GITBUCKET/git/MY_USERNAME/MY_PROJECT # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 Avoid second fetch Seen 0 remote branches > git show-ref --tags -d # timeout=10 ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE Here is my configuration on Jenkins : https://i.stack.imgur.com/jdlTt.png Thank you very much in advance EDIT : My only branche is master --> https://i.imgur.com/lXJ0xyN.png
This is what you can try: Manage Jenkins -> Global Tool Configuration -> Git Check if Path to Git executable is set: C:\PATH\git.exe Dashboard -> select your job -> Configure -> Source Code Management -> select Git Insert your Repository URL and Credentials(Optional) then under Branches to build change */master to */main.
JIRA plugin on jenkins not set the JIRA_ISSUES variable
I have jenkins job for with GitHub Pull Request Builder. In build, I added first step to set the JIRA_ISSUE variable. JIRA: Add related environment variables to build Extracts JIRA information for the build to environment variables. Available variables: JIRA_ISSUES - A comma separated list of issues which are referenced in the version control system changelog JIRA_URL - Primary URL for the JIRA server Typical usage: Add this build step Use the "Progress JIRA issues by workflow action" or "Move issues matching JQL to the specified version" with JQL like: issue in (${JIRA_ISSUES}) Second step is to update these jira issues. <builders> <hudson.plugins.jira.JiraEnvironmentVariableBuilder plugin="jira#3.0.0"/> <hudson.plugins.jira.JiraIssueUpdateBuilder plugin="jira#3.0.0"> <jqlSearch>issue in (${JIRA_ISSUES})</jqlSearch> <workflowActionName>Ready for Review</workflowActionName> <comment>add comment</comment> </hudson.plugins.jira.JiraIssueUpdateBuilder> </builders> When I create PR, and it trigger the job, it not set JIRA_ISSUES GitHub pull request #356 of commit 2e2b92d107a5460c4cc593fcab78c63f800d6472, no merge conflicts. Setting status of 2e2b92d107a5460c4cc593fcab78c63f800d6472 to PENDING with url https://myjenkins.com/job/cicd-myjob-prtest-unittest/69/ and message: 'running tox...' Using context: tox testing [EnvInject] - Loading node environment variables. Building remotely on myslave.node.box.com (linux) in workspace /var/lib/jenkins/workspace/cicd-myjob-prtest-unittest > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url https://mygithub.com/myuser/myproject.git # timeout=10 Fetching upstream changes from https://mygithub.com/myuser/myproject.git > git --version # timeout=10 using GIT_ASKPASS to set credentials Github Service Account Username with token > git fetch --tags --progress https://mygithub.com/myuser/myproject.git +refs/pull/*:refs/remotes/origin/pr/* > git rev-parse refs/remotes/origin/pr/356/merge^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/pr/356/merge^{commit} # timeout=10 Checking out Revision 0ff9e43bbc1385303429f7bcf93fea36e8c455d3 (refs/remotes/origin/pr/356/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f 0ff9e43bbc1385303429f7bcf93fea36e8c455d3 Commit message: "Merge 2e2b92d107a5460c4cc593fcab78c63f800d6472 into 731994024e723b1257374f521b4784060df9e5b5" First time build. Skipping changelog. [JIRA] Setting JIRA_ISSUES to . [JIRA] Updating issues using workflow action Ready for Review. [JIRA] JQL: issue in () [JIRA] Updating issue MYPROJECT-1234 Setting status of 2e2b92d107a5460c4cc593fcab78c63f800d6472 to SUCCESS with url https://myjenkins.com/job/cicd-myjob-prtest-unittest/69/ and message: 'All is well. ' Using context: tox testing Finished: SUCCESS The [JIRA] Updating issue MYPROJECT-1234 is from publisher <publishers> <hudson.plugins.jira.JiraIssueUpdater plugin="jira#3.0.0"> <issueSelector class="hudson.plugins.jira.selector.JqlIssueSelector"> <jql>issue=MYPROJECT-1234</jql> </issueSelector> <labels/> </hudson.plugins.jira.JiraIssueUpdater> </publishers> If I look for change log for commit 2e2b92d107a5460c4cc593fcab78c63f800d6472 it has the jira issue in comment and title. commit 2e2b92d107a5460c4cc593fcab78c63f800d6472 (HEAD -> MYPROJECT-1234, origin/MYPROJECT-1234) Author: myuser <myuser#mygithub.com> Date: Tue Aug 21 15:55:41 2018 -0500 MYPROJECT-1234: Tox testing MYPROJECT-1234 change the data. Why JiraEnvironmentVariableBuilder is not able to set JIRA_ISSUES to MYPROJECT-1234? while same exists in changelog.
Jenkins CodeDeploy plugin errors
So I am using the Jenkins codedeploy plugin to trigger an S3 bucket put of a zip file that is being pulled from my BitBucket repo so then CodeDeploy can deploy the revision to my EC2 instances. Some services via Jenkins succeed, but others fail with this log error. Note: the permissions on /tmp directory is 700. I thought in order to avoid this warning error, "npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})" I could do npm install --no-optional but that clearly wasnt the reason why the build was not successful. Another good thing to note is that multiple services are using the same code deploy application and deployment group to install to the same instance. i.e each service is pulled from a different branch and pushed to the same instance via Code Deploy. I know it sounds super complex, but any help here is really appreciated! Started by user xxxx Building in workspace /var/lib/jenkins/workspace/Livit-Dev_Node > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url https://xxxx # timeout=10 Fetching upstream changes from https://xxxx > git --version # timeout=10 using GIT_ASKPASS to set credentials > git fetch --tags --progress xxxx+refs/heads/*:refs/remotes/origin/* > git rev-parse refs/remotes/origin/BRIDG-oauth- implementation^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/BRIDG-oauth- implementation^{commit} # timeout=10 Checking out Revision 0a2ebd5f1633483cea93d8a627870ac794a6556c (refs/remotes/origin/BRIDG-oauth-implementation) > git config core.sparsecheckout # timeout=10 > git checkout -f 0a2ebd5f1633483cea93d8a627870ac794a6556c Commit message: "Merged in Test-Commit (pull request #22)" > git rev-list --no-walk f7b3a6a9a26e413412bb5ddadec504da9500ba35 # timeout=10 [Livit-Dev_Node] $ /bin/sh -xe /tmp/jenkins6283232840818429990.sh + npm -v 5.6.0 + npm install --no-optional npm WARN livit-backend#1.0.0 No repository field. npm WARN livit-backend#1.0.0 No license field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) up to date in 6.31s Zipping files into /tmp/#13-767184457865657281.zip Failed CodeDeploy post-build step; exception follows. Unable to get file permissions hudson.os.PosixException: Unable to get file permissions null at hudson.util.IOUtils.mode(IOUtils.java:133) at hudson.util.io.ZipArchiver.visit(ZipArchiver.java:55) at hudson.util.DirScanner.scanSingle(DirScanner.java:49) at hudson.util.DirScanner$Glob.scan(DirScanner.java:131) at hudson.FilePath$1.invoke(FilePath.java:473) at hudson.FilePath$1.invoke(FilePath.java:469) at hudson.FilePath.act(FilePath.java:1009) at hudson.FilePath.act(FilePath.java:987) at hudson.FilePath.archive(FilePath.java:469) at hudson.FilePath.zip(FilePath.java:456) atcom.amazonaws.codedeploy.AWSCodeDeployPublisher.zipAndUpload(AWSCodeDeployPublisher.java:358) at com.amazonaws.codedeploy.AWSCodeDeployPublisher.perform(AWSCodeDeployPublisher.java:230) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690) at hudson.model.Build$BuildExecution.post2(Build.java:186) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635) at