[JIRA] (JENKINS-56063) git-plugin fails to expand variables in refspec on initial clone

69 views
Skip to first unread message

plroskin@gmail.com (JIRA)

unread,
Feb 8, 2019, 5:24:02 PM2/8/19
to jenkinsc...@googlegroups.com
Pavel Roskin created an issue
 
Jenkins / Bug JENKINS-56063
git-plugin fails to expand variables in refspec on initial clone
Issue Type: Bug Bug
Assignee: Mark Waite
Attachments: git-clone-config.xml
Components: git-plugin
Created: 2019-02-08 22:23
Environment: Jenkins 2.150.2
Git plugin 4.0.0-rc
Labels: git-plugin variables expansion
Priority: Major Major
Reporter: Pavel Roskin

Git plugin fails to expand variables in the refspec setting. A sure way to trigger the bug is to enable both "Honor refspec on initial clone" and "Wipe out repository & force clone". The config is attached.

Here's an excerpt from the log to the top-level job:

 

 > git fetch --no-tags --progress http://stash/scm/rob/testrepository.git +refs/heads/master:refs/remotes/origin/master${BUILD_ID} # timeout=10
 > git config remote.origin.url http://stash/scm/rob/testrepository.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/master:refs/remotes/origin/master${BUILD_ID} # timeout=10
 > git config remote.origin.url http://stash/scm/rob/testrepository.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Pruning obsolete local branches
Fetching upstream changes from http://stash/scm/rob/testrepository.git
 > git fetch --no-tags --progress http://stash/scm/rob/testrepository.git +refs/heads/master:refs/remotes/origin/master6 --prune # timeout=10

Note that ${BUILD_ID} is not expanded in the first commit, but is expanded at the end where branch specifier is being used.

 

Remove "Wipe out repository & force clone", and the variable is being expanded now.

 

 > git fetch --no-tags --progress http://stash/scm/rob/testrepository.git +refs/heads/master:refs/remotes/origin/master9 --prune # timeout=10
 > git rev-parse refs/remotes/origin/master9^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/refs/heads/master9^{commit} # timeout=10

 

It may seem a trivial issue with ${BUILD_ID}, but it's actually a big problem when I try pulling ${sourceCommitHash} with stash-pull-request-builder. That's why I consider it a major bug. It prevents me from using the correct commit received from Stash REST API and makes me use a suboptimal solution that involves a race condition.

I believe git-plugin should always expand variables in the refspec setting on its own, without relying on the shell.

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

mark.earl.waite@gmail.com (JIRA)

unread,
Feb 11, 2019, 3:16:01 PM2/11/19
to jenkinsc...@googlegroups.com
Mark Waite assigned an issue to Unassigned
Change By: Mark Waite
Assignee: Mark Waite

mark.earl.waite@gmail.com (JIRA)

unread,
Feb 11, 2019, 3:18:02 PM2/11/19
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-56063
 
Re: git-plugin fails to expand variables in refspec on initial clone

If you'll use Pipeline jobs rather than Freestyle jobs, you can allow Groovy to expand the refspec for you and have all the power of the Jenkins Declarative Pipeline and (if needed) scripted Pipeline. I realize that doesn't resolve your issue, but it gives you a path that may allow you to satisfy your use case without waiting for a change in the git plugin.

plroskin@gmail.com (JIRA)

unread,
Feb 12, 2019, 1:29:02 AM2/12/19
to jenkinsc...@googlegroups.com

Thank you. I was able to set up my Stash pull request builders in a way that they don't trigger this issue. But I lost a lot of time before I came to a working setup. I wanted to use strict settings during testing to avoid interference with the previously run tests. It was very disorienting when that strict setup triggered this issue with variable expansion.

It's good that git commands are logged when the installed git binary is used. With jgit, nothing is logged, making it unclear what is expanded and what is not.

mark.earl.waite@gmail.com (JIRA)

unread,
Jan 19, 2020, 9:52:03 PM1/19/20
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
 
Change By: Mark Waite
Labels: expansion git-plugin newbie-friendly variables
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

rishabhbudhouliya+jenkins@gmail.com (JIRA)

unread,
Jan 30, 2020, 3:46:03 PM1/30/20
to jenkinsc...@googlegroups.com

rishabhbudhouliya+jenkins@gmail.com (JIRA)

unread,
Jan 30, 2020, 3:46:03 PM1/30/20
to jenkinsc...@googlegroups.com
Rishabh Budhouliya started work on Bug JENKINS-56063
 
Change By: Rishabh Budhouliya
Status: Open In Progress

rishabhbudhouliya+jenkins@gmail.com (JIRA)

unread,
Jan 30, 2020, 3:48:02 PM1/30/20
to jenkinsc...@googlegroups.com

rishabhbudhouliya+jenkins@gmail.com (JIRA)

unread,
Feb 5, 2020, 3:11:02 PM2/5/20
to jenkinsc...@googlegroups.com

deepanshnagaria@gmail.com (JIRA)

unread,
Feb 6, 2020, 6:12:04 PM2/6/20
to jenkinsc...@googlegroups.com
Deepansh Nagaria updated an issue
Change By: Deepansh Nagaria
Git
0...........................................................................0Git
plugin fails to expand variables in the refspec setting. A sure way to trigger the bug is to enable both "Honor refspec on initial clone" and "Wipe out repository & force clone". The config is attached.


Here's an excerpt from the log to the top-level job:

 
{code:java}

> git fetch --no-tags --progress http://stash/scm/rob/testrepository.git +refs/heads/master:refs/remotes/origin/master${BUILD_ID} # timeout=10
> git config remote.origin.url http://stash/scm/rob/testrepository.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/master:refs/remotes/origin/master${BUILD_ID} # timeout=10
> git config remote.origin.url http://stash/scm/rob/testrepository.git # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
> git clean -fdx # timeout=10
Pruning obsolete local branches
Fetching upstream changes from http://stash/scm/rob/testrepository.git
> git fetch --no-tags --progress http://stash/scm/rob/testrepository.git +refs/heads/master:refs/remotes/origin/master6 --prune # timeout=10

{code}

Note that ${BUILD_ID} is not expanded in the first commit, but is expanded at the end where branch specifier is being used.

 

Remove "Wipe out repository & force clone", and the variable is being expanded now.

 
{code:java}

> git fetch --no-tags --progress http://stash/scm/rob/testrepository.git +refs/heads/master:refs/remotes/origin/master9 --prune # timeout=10
> git rev-parse refs/remotes/origin/master9^{commit} # timeout=10
> git rev-parse refs/remotes/origin/refs/heads/master9^{commit} # timeout=10
{code}

 

It may seem a trivial issue with ${BUILD_ID}, but it's actually a big problem when I try pulling ${sourceCommitHash} with stash-pull-request-builder. That's why I consider it a major bug. It prevents me from using the correct commit received from Stash REST API and makes me use a suboptimal solution that involves a race condition.

I believe git-plugin should always expand variables in the refspec setting on its own, without relying on the shell.

 

mark.earl.waite@gmail.com (JIRA)

unread,
Feb 6, 2020, 7:19:03 PM2/6/20
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
Change By: Mark Waite

0...........................................................................0Git
Git plugin fails to expand variables in the refspec setting. A sure way to trigger the bug is to enable both "Honor refspec on initial clone" and "Wipe out repository & force clone". The config is attached.
Reply all
Reply to author
Forward
0 new messages