[JIRA] (JENKINS-18834) Initial git fetch ignore prune settings

12 views
Skip to first unread message

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

unread,
Nov 1, 2019, 12:06:02 PM11/1/19
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
 
Jenkins / Bug JENKINS-18834
Initial git fetch ignore prune settings
Change By: Mark Waite
Summary: Initial git fetch ignore prune settings of the job
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

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

unread,
Nov 1, 2019, 12:54:02 PM11/1/19
to jenkinsc...@googlegroups.com

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

unread,
Nov 1, 2019, 1:24:02 PM11/1/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-18834
 
Re: Initial git fetch ignore prune settings
[~etoews] that surprises me, since the {{--prune}} argument is added to the {{git fetch}} command which is used to fetch the latest updates from the remote repository.

Since the command in the output you provided does not include the {{\--prune}} argument, that must indicate that the initial fetch is not honoring the prune argument.  There are (unfortunately) two calls to {{git fetch}} when the git plugin retrieves changes from the remote repository.  The second fetch is likely the one that would include the {{\--prune}} argument. A future optimization will be needed to remove that extra call to {{git fetch}} or a specific fix for this bug to cause that initial fetch to include the {{\--prune}} argument.

You might also try adding the "Honor refspecs in initial clone" option that is available in the "Advanced clone options".  It might have a side-effect of including the {{\--prune}} argument in the first fetch of the repository.


I've written an [automated test|https://github.com/MarkEWaite/jenkins-bugs/tree/JENKINS-18834] that confirms the bug exists.

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

unread,
Nov 1, 2019, 1:50:03 PM11/1/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-18834
[~etoews] that surprises me, since the {{--prune}} argument is added to the {{git fetch}} command which is used to fetch the latest updates from the remote repository.

Since the command in the output you provided does not include the {{\--prune}} argument, that must indicate that the initial fetch is not honoring the prune argument.  There are (unfortunately) two calls to {{git fetch}} when the git plugin retrieves changes from the remote repository.  The second fetch is likely the one that would include the {{\--prune}} argument. A future optimization will be needed to remove that extra call to {{git fetch}} or a specific fix for this bug to cause that initial fetch to include the {{\--prune}} argument.

You might also try adding the "Honor refspecs in initial clone" option that is available in the "Advanced clone options".  It might have a side-effect of including the {{\--prune}} argument in the first fetch of the repository.

I've written an [automated test|https://github.com/MarkEWaite/jenkins-bugs/ tree blob /JENKINS-18834 /Jenkinsfile ] that confirms the bug exists.

everett.toews@gmail.com (JIRA)

unread,
Nov 3, 2019, 4:14:03 PM11/3/19
to jenkinsc...@googlegroups.com

Mark Waite Thanks a lot for taking the time to confirm the bug and write a test.

I should also have mentioned my current versions. They are:

  • Jenkins: 2.176.2
  • Git: 3.10.0
  • Git client: 2.7.7

Unfortunately, specifying any Additional Behaviours on a pipeline doesn't work for us. We're using Jenkins with OpenShift and it automatically overwrites any such config changes.

I see JGit referenced in a lot of issues relating to pruning. Is a possible workaround simply using the JGit plugin?

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

unread,
Nov 3, 2019, 5:41:03 PM11/3/19
to jenkinsc...@googlegroups.com

I would be surprised if JGit resolved it, but it is easy to check. Follow the instructions to enable JGit, then add gitTool: 'jgit' to the checkout scm., The Pipeline syntax helper in Jenkins will suggest the correct configuration once you've enabled JGit.

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

unread,
Nov 3, 2019, 7:00:04 PM11/3/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-18834
I would be surprised if JGit resolved it, but it is easy to check.  Follow the instructions to [enable JGit|https://github.com/jenkinsci/git-client-plugin/blob/master/README.md#enabling-jgit], then add

{ { code:java}
gitTool: 'jgit'
{code
} }

to the {{checkout scm}}.,  The {{Pipeline syntax}} helper in Jenkins will suggest the correct configuration once you've enabled JGit.
Reply all
Reply to author
Forward
0 new messages