I would like to be able to see which files have changed between my current branch and the master branch during a jenkins build.
in my jenkinsfile i have the below code.
git diff-tree -r --no-commit-id --name-only ${env.GIT_COMMIT} origin/master
but i get the below error
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Any help would be appreciated..it'd be great if someone could tell me what i'm doing wrong or devise an alternate solution that will give me the filepaths of files that have changed.
fyi, the above command works locally, but not in jenkins.
I finally found the fix for this. @vonc pointed me in the right direction, but the link he provided didn't make any sense.
Here's the link that helped me.
https://issues.jenkins-ci.org/browse/JENKINS-45666?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel
You have to add a refspec in the jenkins settings for the project. If you are using github organisations you have to apply in the organisations settings as you can't change a specifc repos settings. Anyway, this works for me.
Add this as a refspec.
+refs/heads/master:refs/remotes/@{remote}/master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With