How to Trigger a Jenkins Job on Pull Request Close Event from Webhook - github

We have an Enterprise Jenkins box with the GitHub Plugin that scans orgs and creates jobs for each branch/PR etc. Repos then have a webhook which send push/pull request events to the webhook, which builds them.
I'm trying to work out how to destroy ephemeral environments after a Ent. GitHub PR has been closed. I figured the best way to do this would be to have the webhook invoke the job and read the GH payload on the PR close event, however it doesn't appear like this is an option from any of the GH plugin settings on the org? The webhook simply disables job on the close event rather than building.
We don't have GitHub Actions available, so that's not an avenue. How else could I invoke a build upon PR close?

Related

GitHub and Jenkins Pull Request Check

I have a question regarding GitHub checks for Pull Request. I have an integration between GitHub and Jenkins, which each time a Pull Request is opened it will trigger a Jenkins jobs to run. But how do I configure it so that if the Jenkins job is successful, it will pass back a Check validation back to GitHub Pull Request as a success as shown in below image?
I created a GitHub App and the Jenkins job is able to trigger during Pull Request, but no status is pass back. I think I am missing a step somewhere, but not sure which.

How receive hook from Bitbucket on JIRA and process this hook data?

How receive hook from Bitbucket on JIRA and process this hook data?
I can't figure out how to properly create a hook listener from Bitbucket to JIRA.
As I can see:
1) There is a branch in Bitbucket
2) A commit is added to the branch and a Pull Request is created.
3) The reviewer clicks Approve at Pull Request and at this moment a change in the status of the task should occur in JIRA, which in one of the fields contains the name of the branch
I understand how to send a hook from BitBucket, but how to get a hook and process it in JIRA
I do not understand how to implement this, have any ideas?
I figured it out, it's simple via WebHooks
I used the plugin JIRA Automation
Bitbucket sends the hook to the JIRA with the transfer of the secret
(basic authorization);
JIRA gets the hook and processes the hook
using the plugin
JIRA then sends a request to TeamCity to build a
specific branch using a plugin;
TeamCity is building a specific branch and sends the hook
to JIRA, and JIRA processes the hook from the
TeamCity and performs the actions

Triggering Jenkins Multibranch Pipeline automatically if a PR is raised on GitHub

I am using Jenkins Multibranch pipeline.
I've configured the APIs (github-webhook and ghprbhook) on GitHub.
Currently, If I click on "Scan Repository Now/Scan Repository Log" in Jenkins, the Jenkins will go through the GitHub and creates a new PR job in Jenkins if there are any PR on GitHub.
So I need to trigger this Multibranch pipeline whenever there is a Pull Request raised on GitHub. I want this pipeline to trigger automatically when there is a PR on GitHub.
What do I need to do to achieve this approach?
Is it possible to trigger Multibranch pipeline automatically whenever a PR is raised on GitHub?
To achieve this, I have selected only "Push and Pull Request" under "Let me select individual events" section of GitHub Webhooks.
PS: The GitHub branches are automatically detected in Jenkins.
Du you use the GitHub pull request builder plugin?
This Jenkins plugin builds pull requests from GitHub and will report the results directly to the pull request via the GitHub Commit Status API
When a new pull request is opened in the project and the author of the pull request isn't whitelisted, builder will ask Can one of the admins verify this patch?. One of the admins can comment ok to test to accept this pull request for testing, test this please for one time test run and add to whitelist to add the author to the whitelist.
If an author of a pull request is whitelisted, adding a new pull request or new commit to an existing pull request will start a new build.
A new build can also be started with a comment: retest this please.

Triggering Jenkins Multibranch pipeline when there is a pull request created in GitHub

I'm using Jenkins Multibranch pipeline. I've configured the APIs(github-webhook and ghprbhook) in GitHub. I want to trigger the Multibranch Pipeline whenever there is a Pull Request on GitHub (without using periodical option).
For example, if i create pull request on GitHub, then the Jenkins Multibranch pipeline should start scanning and build the Jenkinsfile automatically.
What do i need to do to achieve this?
I would love to try if there are any suggestions.
Under the webhook section, you can choose Let me select individual events option. Under that you can have push selected by default and also can select Pull Request which helps you to do wnat you are looking for Pull request opened, closed, reopened, edited, assigned, unassigned, review requested, review request removed, labeled, unlabeled, or synchronized.
To achieve this, I have selected "Send me everything" under GitHub Webhooks section.
Then I was able to trigger builds automatically whenever a PR is raised on GitHub.
As #RSharma mentioned, I have selected only "Push and Pull Request" under "Let me select individual events" section.
PS: The GitHub branches are automatically detected in Jenkins.

Showing Jenkins pipeline status against pull requests in GitHub

I have recently started using Jenkins Pipelines and have a multibranch job configured which is happily picking up Jenkinsfile on one of my branches.
I have seen in screenshots on posts\articles that Jenkins can report back to pull requests in GitHub the status of whether the branch has passed\failed checks performed in the pipeline.
I am not seeing any such feedback for my pull request I have opened, I can see in Jenkins it has triggered a pipeline build which has passed.
How can I get the notification to show the pipeline checks have passed in GitHub. Do I need to configure something else?
I found out this was simply down to me using the Git instead of GitHub sources option when configuring the multibranch pipeline job in Jenkins.
The docs for the GitHub Branch Source plugin gave me the clues!
I now get status messages on my pull requests showing whether pipeline checks are pending\failed\passed.
Check out the Github Pull Request Builder Plugin, it should do what you require: https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin