Recently started using PR decoration feature of SonarQube 8.2. With PR analysis I am seeing the warning:
Could not find ref 'master' in refs/heads, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.
We are using Jenkins pipeline with Jenkinsfile and I would like to fetch +refs/heads/master:refs/remotes/origin/master during the build process. This is what we have now:
Thanks Ann for taking time to reply here. But this does not answer my question. In fact the info quoted was already included in the question. Thanks anyway.
The accepted answer in that thread indicates that an extra commit was being made in/by the pipeline, which resulted in the “Could not find” message. It also tells how to get rid of the warning.
TBH, we’re not going to be a huge amount of help here with the part of your pipeline that happens before analysis.
Ann, thanks for your help. I did not mean to be negative. I just wanted to point out that I had done my research before posting here and I had in fact seen the same thread & solution there, and even referenced the solution in my first post. My question was about how someone would fetch an extra branch in a Jenkinsfile using the ‘checkout’ command. With this (fetching master along with PR branch) being a must have step for PR analysis, I thought someone would have already figured out how to do that as part of ‘checkout’ step in a Jenkins pipeline.