Also, if I log directly into Stash and cd to the repository, the git branch 
command does NOT show any of these phantom origin/pull-requests branches. 
 These seem to be something being fabricated by Jenikins.


On Wednesday, July 13, 2016 at 9:01:30 AM UTC-7, Michael Giroux wrote:
>
> BTW, when I clone the repository to my local workstation, the 
> origin/pull-requests/* branches do NOT appear in "git branch -a".  However, 
> when I log into the Jenkins server, and cd to the job directory, the 
> pull-request branches DO appear, so Git plugin is using something special 
> to cause the branches to be pulled.  This too is confusing.
>
> On Wednesday, July 13, 2016 at 8:58:52 AM UTC-7, Michael Giroux wrote:
>>
>> This question involves Git plugin, Stash, and SonarQube integration, so 
>> there are multiple bits that we need to coordinate.
>>
>>
>>    1. We are using Stash with the Jenkins Web Hook to trigger builds 
>>    when developers push code to a branch.
>>    2. The build checks the code out to a local branch using the remote 
>>    branch name.
>>    3. The build runs sonar analysis and sets the sonar.branch property 
>>    to the local branch name.
>>    4. The team creates a pull request for the branch.
>>    5. When the pull request is merged, the branch in Stash is deleted, 
>>    and the SonarQube project for the branch is deleted.
>>
>> In some cases, what we see is a bit different.  By the time the jenkins 
>> job is executed for a commit, the pull request has already been created. 
>>  In this case, when the Git plugin pulls the code and does the checkout on 
>> the commit, there are two branches, the one the developer pushed, and the 
>> one Stash created for the PR.  Git plugin is setting the GIT_BRANCH 
>> property to origin/pull-requests/23/from  instead of 
>> origin/feature/branchname.
>>
>> In this case, when the build runs, the sonar.branch ends up being set to 
>> feature-branchname and we end up with a SonarQube project named 
>> "groupId:artifactid:pull-requests-23-from"  instead of 
>> "groupId:artifactId:feature-branchname".  
>>
>> Now, when the team merges the pull request in Stash, the options to 
>> delete the branch and cleanup the SonarQube project are selected.  The 
>> Stash branch "feature/branchname" is deleted, but the SonarQube project is 
>> not deleted because the SonarQube project name (...:pull-requests-23-from) 
>> does not match the Stash branch name being deleted.
>>
>> The problem seems to be caused by the fact that the commit has two 
>> branches associated with it.  From our perspective, the easiest solution is 
>> to force Git to use the branch name that was pushed by the developer, and 
>> to ignore pull-request type branches.
>> "Checking out Revision c3db27a8df3b68e927af8c5e01791bc270e7a90b 
>> (origin/pull-requests/6737/from, 
>> origin/DE00000-TA00000-switchCaseLines+addPrivateConstructor)"
>>
>> "GIT_BRANCH=origin/pull-requests/6737/from"
>>
>>
>> How can we prevent Git plugin from using the pull-requests branch name?
>>
>> Michael
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c1c99e02-d58f-4d4b-a79d-b95ffc481f1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to