-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify pull request merge builds #1
Comments
You're right, the I'm afraid it wouldn't make much sense to make it available for ordinary branches. What I think you're probably looking for is some kind of trigger for when a PR is closed/merged. Technically GitHub supports this t(https://developer.github.com/v3/activity/events/types/#pullrequestevent) so it should be possible to do. And I think the plumbing is already in place in the If you feel up to it you could submit a PR, otherwise I'll add it to my todo list! To answer your last question, this isn't currently supported by the Pipeline Github Plugin, but I think it would be a welcome addition. As for is there a possible workaround, I think you might be able to check the branch history/log and determine if the latest commit was a merge commit and perhaps check the commit message, to determine the originating branch/pr.. I haven't tried to investigate this approach myself but a quick google found these:
I hope this gives you a starting point, otherwise I would really appreciate a PR. |
Thanks for the ideas. In the end, I just decided to use the commit hash and query the GitHub API: def res = checkout scm
def commitHash = res['GIT_COMMIT']
withCredentials([usernameColonPassword(credentialsId: 'github-credentials', variable: 'AUTH')]) {
pullRequestNumber = sh script: "curl -s -u $AUTH 'https://api.github.com/repos/<org>/<repo>/pulls?state=closed' | jq -j '.[] | select(.merge_commit_sha == \"$commitHash\") | .number'", returnStdout: true
} I might still have a use for the PR trigger, though, and I started the initial work. If I get an opportunity to finish it, I'll submit a PR. Thanks for the help! |
Hello, we have this same desire (run job on a branch and be able to retrieve PR details for a merge to that branch). I am interested to contribute to the library but want to be sure the feature hasn't been added since this issue and that PRs would be accepted! @aaronwalker - tagging you because I see you previously merged changes into this repo. Can you give your advice/thoughts? |
Also wondering if/how this PR relates to #91 - not sure if that is what is referenced by #1 (comment)?
|
I have been watching this plugin and was excited to see the v1 release, thanks! I have high hopes for this plugin and its usefulness.
I'm using the GitHub Organization plugin with automatic job creation and webhooks.
Here's my workflow:
When my PR build executes, I am able to access the
pullRequest.merged
property, and it isfalse
as I would expect. However, when I merge the PR, and the master build runs, I am not able to access thepullRequest
global variable (presumably because the build is executing against master, and not a PR).I was hoping I would be able to check the
pullRequest.merged
property in the master build to determine that a PR has just been merged, and execute some additional logic. Is there another way to achieve this, should the approach above work, or is this just not supported at the moment?The text was updated successfully, but these errors were encountered: