Hi all,
I'm having the below issue.
I was change my code to use GIT Reference repository in Jenkinsfile code such as below.
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.
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).
branches: [[name: 'origin/* ]]
branches: [[name: env.BRANCH_NAME]]
refspec: "+refs/heads/*:refs/remotes/origin/*",
refspec: "+refs/heads/pr/*:refs/remotes/origin/pr/*",
refspec: "+refs/heads/*:refs/remotes/origin/* +refs/heads/pr/*:refs/remotes/origin/pr/*",
--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d69b5c1c-e4f8-42e4-ba75-084ada0b653a%40googlegroups.com.
As far as I can tell, you want to:
- Use declarative pipeline for clarity of the pipeline
- Skip the default checkout so that you can tune the performance of checkout
- Perform your own checkout using a reference repository
- Use the same Jenkinsfile on branches and on pull requests so that pull requests can be merged into target branches easily
- Checkout in the workspace to a branch with the same name as the branch on the git server
Based on those assumptions, I created a sample job and a pull request that targets the master branch and meets those requirements. When a pull request is being evaluated, the changes on the pull request are detected and used. When the master branch is being evaluated, its changes are detected and used.Please refer to the sample job and the techniques used in the sample job. Note that you will need the most recent release of the git plugin for references to the scm variable.Mark Waite
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f5630876-867e-4b30-9de5-1d28fa8f8eec%40googlegroups.com.
You can confirm that a reference repository is being used by looking for the file .git/objects/info/alternates in the repository.The file in my sample repository includes the text:/home/mwaite/git/bare/jenkins/jenkins.git/objects
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f5630876-867e-4b30-9de5-1d28fa8f8eec%40googlegroups.com.
Hi Mark,
Actually where I can find the file you mention "/home/mwaite/git/bare/jenkins/jenkins.git/objects" in your repository MarkEWaite/jenkins-bugs ?
Finally I able to get use the GIT Reference repository in my builder machine. But to get use that I had to replace my old Jenkins Configurations by giving the GIT reference repository path as below.
It's really surprised me because, as above screenshot when I include that reference-path configuration in Jenkins GUI only it starting to getting use my Jenkinsfile's SCM checkout stage code configurations.
Still I have a small issue as you can see below Jenkins console-output it says "using Shallow fetch with depth 3" 02 times. (previously it was only one time. So I'm afraid that Jenkins uses both configurations such as Jenkins GUI and Jenkinsfile code configurations here. Is it okay since it may not do any harm to my builds ?
You can confirm that a reference repository is being used by looking for the file .git/objects/info/alternates in the repository.
On Tuesday, February 25, 2020 at 3:03:34 AM UTC-5, Amila Gunathilake wrote:Hi Mark,
Actually where I can find the file you mention "/home/mwaite/git/bare/jenkins/jenkins.git/objects" in your repository MarkEWaite/jenkins-bugs ?
Finally I able to get use the GIT Reference repository in my builder machine. But to get use that I had to replace my old Jenkins Configurations by giving the GIT reference repository path as below.
It's really surprised me because, as above screenshot when I include that reference-path configuration in Jenkins GUI only it starting to getting use my Jenkinsfile's SCM checkout stage code configurations.
Still I have a small issue as you can see below Jenkins console-output it says "using Shallow fetch with depth 3" 02 times. (previously it was only one time. So I'm afraid that Jenkins uses both configurations such as Jenkins GUI and Jenkinsfile code configurations here. Is it okay since it may not do any harm to my builds ?