On Tuesday, February 18, 2020 at 6:09:43 PM UTC-7, Amila Gunathilake wrote: > > Hi all, > > I'm having the below issue. > > I was change my code to use GIT Reference repository in Jenkinsfile code > such as below. > > > [image: image-2020-02-18-04-21-49-733.png] > > > > So I made a new pull request in GIT-HUB for the purpose of merge these > changes into my master branch. > > But when the Pull-Request running I saw in my builder machine (workspace) > its not downloading (fetching) the relevant Remote Pull-Request > Head/Branch/ because in my workspace (builder-machine) local branch always > checkout with the master branch and fetching from the master branch and not > checkout for the correct Pull Request Head. > > [image: image-2020-02-18-04-44-45-417.png] > > > > eg: Above screenshot is the way that my local workspace's .git > HEAD > file looks like in the Pull Request I created after above code changes. And > as you can see in the HEAD file it's automatically checkout in to the > master branch instead of checking out into the relevant Pull-Request hash > (tag). > > - But below is the correct screenshot I captured from any of other > Pull Requests, which should be the correct way to show the checkout branch > or the HEAD. > > > [image: image-2020-02-18-04-46-58-927.png] > > I hope you will understand my situation here? Please let me know if you > guys need further information. > > *I throughly suggest that I want some code to replace above Yellow color > highlighted sections.* > > So please could anyone please give some advice regarding this issue ? > > > The value of 'branches' that you're using is incorrect. In the triggers section you're declaring that if the env.BRANCH_NAME is master, then perform builds on a specific schedule. Use the same env.BRANCH_NAME in the branches section by changing from:
branches: [[name: 'origin/* ]] to: branches: [[name: env.BRANCH_NAME]] If the env.BRANCH_NAME is defined for the trigger case, then it should also be defined and available to use when defining the branch name. The duplicate value of refspec will likely prevent the checkout from detecting any changes in your repository. Change from: refspec: "+refs/heads/*:refs/remotes/origin/*", refspec: "+refs/heads/pr/*:refs/remotes/origin/pr/*", to: refspec: "+refs/heads/*:refs/remotes/origin/* +refs/heads/pr/*:refs/remotes/origin/pr/*", The syntax you're using provides a value for refspec then replaces it with a different value for refspec. The corrected syntax provides the default refspec plus the "pr" namespace refspec as a single argument so that both will be used. Mark Waite -- 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 jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a801aca3-5fa4-4043-a674-f8a9a6bc9dee%40googlegroups.com.