-
Bug
-
Resolution: Fixed
-
Minor
-
Windows,
Jenkins v. 2.235.5
Git plugin v. 4.5.0
-
-
4.14.0
Hint from "Branches to build" option in "Pipeline script from SCM" option tells that:
${ENV_VARIABLE} It is also possible to use environment variables. In this case the variables are evaluated and the result is used as described above. E.g. ${TREEISH}, refs/tags/${TAGNAME}, ...
However, environment variable not evaluated, resulting following error on script call:
hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress --prune -- origin +refs/heads/${SCRIPTS_REPO_BRANCH_NAME}:refs/remotes/origin/${SCRIPTS_REPO_BRANCH_NAME}" returned status code 128: stdout: stderr: load pubkey "C:\\Windows\\TEMP\\jenkins-gitclient-ssh2322785094198445571.key": invalid format fatal: couldn't find remote ref refs/heads/${SCRIPTS_REPO_BRANCH_NAME} at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573) at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) Finished: FAILURE
Steps to reproduce:
- Create any pipeline script in git repo
- Go to "Configure System" menu in your Jenkins web app (%YOUR_URL%/configure)
- Create new environment variable "SCRIPTS_REPO_BRANCH_NAME", set its value to the branch name, you script lies under
- Create new pipeline script (%YOUR_URL%/view/all/newJob), "Pipeline"
- Select "Pipeline script from SCM" menu
- Fill all required field, set "Branches to build" = ${SCRIPTS_REPO_BRANCH_NAME}
- Run script, see the error, mentioned above
- Go back to script configuration replace "Branches to build" value with plain branch name
- Run script again, see it checked out and picked properly
- links to
[JENKINS-64406] Git plugin does not evaluate environment variables for branch option when use "Pipeline script from SCM" option
Description |
Original:
Hint from "Branches to build" option in "Pipeline script from SCM" option tells that:
{code:java} ${ENV_VARIABLE} It is also possible to use environment variables. In this case the variables are evaluated and the result is used as described above. E.g. ${TREEISH}, refs/tags/${TAGNAME}, ... {code} {{}} However, environment variable not evaluated, resulting following error on script call: {code:java} hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress --prune -- origin +refs/heads/${SCRIPTS_REPO_BRANCH_NAME}:refs/remotes/origin/${SCRIPTS_REPO_BRANCH_NAME}" returned status code 128: stdout: stderr: load pubkey "C:\\Windows\\TEMP\\jenkins-gitclient-ssh2322785094198445571.key": invalid format fatal: couldn't find remote ref refs/heads/${SCRIPTS_REPO_BRANCH_NAME} at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573) at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) Finished: FAILURE {code} Steps to reproduce: # Create any pipeline script in git repo # Go to "Configure System" menu in your Jenkins web app (%YOUR_URL%/configure) # Create new environment variable "SCRIPTS_REPO_BRANCH_NAME", set its value to the branch name, you script lies under # Create new pipeline script (%YOUR_URL%/view/all/newJob), "Pipeline" # Select "Pipeline script from SCM" menu # Fill all required field, set "Branches to build" = ${SCRIPTS_REPO_BRANCH_NAME} # Run script, see the error, mentioned above # Go back to script configuration replace "Branches to build" value with plain branch name # Run script again, see it checked out and picked properly |
New:
Hint from "Branches to build" option in "Pipeline script from SCM" option tells that:
{code:java} ${ENV_VARIABLE} It is also possible to use environment variables. In this case the variables are evaluated and the result is used as described above. E.g. ${TREEISH}, refs/tags/${TAGNAME}, ... {code} However, environment variable not evaluated, resulting following error on script call: {code:java} hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress --prune -- origin +refs/heads/${SCRIPTS_REPO_BRANCH_NAME}:refs/remotes/origin/${SCRIPTS_REPO_BRANCH_NAME}" returned status code 128: stdout: stderr: load pubkey "C:\\Windows\\TEMP\\jenkins-gitclient-ssh2322785094198445571.key": invalid format fatal: couldn't find remote ref refs/heads/${SCRIPTS_REPO_BRANCH_NAME} at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573) at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) Finished: FAILURE {code} Steps to reproduce: # Create any pipeline script in git repo # Go to "Configure System" menu in your Jenkins web app (%YOUR_URL%/configure) # Create new environment variable "SCRIPTS_REPO_BRANCH_NAME", set its value to the branch name, you script lies under # Create new pipeline script (%YOUR_URL%/view/all/newJob), "Pipeline" # Select "Pipeline script from SCM" menu # Fill all required field, set "Branches to build" = ${SCRIPTS_REPO_BRANCH_NAME} # Run script, see the error, mentioned above # Go back to script configuration replace "Branches to build" value with plain branch name # Run script again, see it checked out and picked properly |
Assignee | Original: Mark Waite [ markewaite ] |
Labels | Original: git jenkins | New: git newbie-friendly |
Status | Original: Open [ 1 ] | New: In Progress [ 3 ] |
Status | Original: In Progress [ 3 ] | New: In Review [ 10005 ] |
Released As | New: 4.14.0 | |
Resolution | New: Fixed [ 1 ] | |
Status | Original: In Review [ 10005 ] | New: Closed [ 6 ] |
Remote Link | New: This issue links to "PR 1305 resolving the issue (Web Link)" [ 28364 ] |