pull-request-notifier-for-bitbucket
pull-request-notifier-for-bitbucket copied to clipboard
Getting list of changed files from jenkins
Team,
We'd like to get a list of the git files changed for a PR and thought we could do the following
git diff --name-only SHA1 SHA2
or more explicitly
git diff --name-only $PULL_REQUEST_FROM_HASH $PULL_REQUEST_TO_HASH
This is for a forked branch merging to a main central branch. Whilst this works for some commits otherwise come up with the error tinvalid object not found for one of the commits.
Is this the best way to achieve this? How do others build a list of files?
Many thanks
Matt
Ic you clone the forked repo you also need to fetch from the main repo.
thanks @tomasbjerre this is certainly when I've cloned a fork locally. If I'm operating on a clone how can I also fetch the main repo within the clone? You mean clone the none forked repository? I wanted to do these commands from just the fork if possible e.g. commands other developers can use without having to retrieve anything else. When you say fetch can we not just reference the main repo with the command?
You need to do git fetch --all $PULL_REQUEST_TO_SSH_CLONE_URL
Den 8 dec. 2016 17:27 skrev "mattadamson" [email protected]:
thanks @tomasbjerre https://github.com/tomasbjerre this is certainly when I've cloned a fork locally. If I'm operating on a clone how can I also fetch the main repo within the clone? You mean clone the none forked repository? I wanted to do these commands from just the fork if possible e.g. commands other developers can use without having to retrieve anything else. When you say fetch can we not just reference the main repo with the command?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/168#issuecomment-265784302, or mute the thread https://github.com/notifications/unsubscribe-auth/AAa1EzIerlZWRTmK8cmjG81jf9Uem-voks5rGDADgaJpZM4LH_Mm .
I currently have this
git clone $PULL_REQUEST_TO_HTTP_CLONE_URL
cd *
git reset --hard $PULL_REQUEST_TO_HASH
git status
git remote add from $PULL_REQUEST_FROM_HTTP_CLONE_URL
git fetch from
git merge $PULL_REQUEST_FROM_HASH
git --no-pager log --max-count=10 --graph --abbrev-commit
So you mean instead of the initial git clone use the above?
Will this pull a lot more data too for the whole repository as I want to make the build as quick as possible?
Perhaps change git fetch from to git fetch --all
Den 8 dec. 2016 18:02 skrev "mattadamson" [email protected]:
I currently have this
git clone $PULL_REQUEST_TO_HTTP_CLONE_URL cd * git reset --hard $PULL_REQUEST_TO_HASH git status git remote add from $PULL_REQUEST_FROM_HTTP_CLONE_URL git fetch from git merge $PULL_REQUEST_FROM_HASH git --no-pager log --max-count=10 --graph --abbrev-commit
So you mean instead of the initial git clone use the above?
Will this pull a lot more data too for the whole repository as I want to make the build as quick as possible?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/168#issuecomment-265794272, or mute the thread https://github.com/notifications/unsubscribe-auth/AAa1Ez5CiPfP21Y6lVTD_ahazMYNoYWkks5rGDg-gaJpZM4LH_Mm .
I was trying to do the same thing and found it easier to query bitbucket instead: https://developer.atlassian.com/static/rest/bitbucket-server/4.12.0/bitbucket-rest.html#idp2350048
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes
then used groovy to parse the json
Hi rmuhic, I am interested in you API solution, could you please paste your groovy script? I dont have any experience on groovy. thank you!