-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins ver. 2.121.2
Git plugin 3.9.1
Java version 1.8.0_152
Windows 10 (master) (64bit)
Windows 7&10 (slaves) (64bit)
Installed Git version 2.14.2.windows.3
Description of expected/wanted behaviour:
- Build/checkout branch 'specificbranch'
- before build merge 'specificbranch' with 'masterbranch' with upstream tracking of 'masterbranch'
- when build starts expect workspace to be in a merged version of 'masterbranch' with 'specificbranch'
Setup:
- pipeline job
- parameters
- repoName: full repository name
- branchRef: full branch ref (ex refs/heads/master)
- SCM git
- lightweight checkout is disabled
- repository: ssh://urltoourserver/git/$repoName
- name either blank or fixed as 'origin'
- no custom refspec
- branches to build: ${branchRef}
- Additional behaviour:
- advanced sub-modules behaviours (recursive update)
- wipe repository & force clone
- Check out to specific local branch (left empty) (note 1)
- Merge before build
- name of repository: origin (note 2)
- branch to merge to: stable
- merge strategy: default
- ff-mode: --ff-only
- parameters
Observations:
Specifying name of repository of the merge before build option as 'origin' and branch to merge to as 'stable' results in the behaviour that it tries to force checkout 'origin/stable' which results in a 'HEAD detached at origin/stable' situation. And then it'll merge the branch specified by ${branchRef} in to the detached head.
After the merge the plugin proceeds to checkout the ${branchRef} using 'checkout -b branchname hashvalue'.
This results in a local branch, which does not track the remote branch and is not the result of the previous merge action.
The previous merge action is also not available as it is lost after the latest checkout action(s)
note 1:
Specifying ** does not work. Will complain that ** is not a valid branch.
> git.exe checkout -b ** origin/stable
hudson.plugins.git.GitException: Command "git.exe checkout -b ** origin/stable" returned status code 128:
stdout:
stderr: fatal: '**' is not a valid branch name.
note 2:
I have to explicitly give this a value, leaving it blank does not work. It'll default to null
Merging Revision 12d019d59117daa84b4d3d4a570a996c387b5199 (refs/remotes/origin/release/0.1.2) to null/stable, UserMergeOptions{mergeRemote='null', mergeTarget='stable', mergeStrategy='default', fastForwardMode='--ff-only'}
> git.exe rev-parse "null/stable^{commit}" # timeout=10
hudson.plugins.git.GitException: Command "git.exe rev-parse "null/stable^{commit}"" returned status code 128:
stdout: null/stable^{commit}
stderr: fatal: ambiguous argument 'null/stable^{commit}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] – [<file>...]'
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2016)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1984)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1980)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1612)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1624)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:809)
at hudson.plugins.git.GitAPI.revParse(GitAPI.java:316)
at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:66)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1094)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1187)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:144)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:303)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
I am working around this issue by not merging before build and just doing it myself:
and/or