How to capture PR CREATION event in bitbucket - bitbucket

‘’’’
Need to know if there is any possible way to capture the event of pull request creation in bitbucket to write a custom script using this event.
Dont want PR to trigger any automatic build instead just need capture the pr creation event to write a custom python script to trigger certain activities through script run.
One option is to read/continuous poll the bit bucket PR creation page to identify the activity/event but it sounds to be a bad scripting standard and not a good practice.
Is there any git command to identify PR creation at feature branch and to merge into parent(say its DEV) and also git command to capture PR default reviewer names???
So that, these git commandS can be used in script To track if any PR is raised?
Verified many websites and read many articals and unfortunately no where found the possibility to capture the PR creation event in bit bucket?
Great if anyone can post the possibility to capture the event to write our own custom logic with the PR event capture
‘’’’

PR is not a part of git. It's a concept unique to code hosting sites like Bitbucket, Github, etc. Therefore, theoretically it's not possible to capture PR creation event using git tool alone.
You can poll the Bitbucket REST Apis for the PR list. The response is in Json format, stable and easy to parse, so it's not really a bad practice (as when you parse the raw html).
Another way is to set up a Bitbucket webhook that triggers on PR creation event. You then need to run a web server (something like this) to accept the webhook call and run the corresponding scripts.

Related

Prevent GitHub Webhook being sent from Pushing of Tag

I am having an issue with my Jenkins pipeline that pushes a tag as one of the steps, this ultimately kicks off the build again causing a loop.
Doesn't GitHub have a way of only sending a webhook with a source commit to the repo and not a tag?
When you register for a given type of webhook with GitHub, you get notifications for every webhook of that type. Filtering is not possible for efficiency reasons, since GitHub sends massive numbers of webhook payloads. The assumption is that your service will discard any events you don't care about.
If you don't want Jenkins to build when a tag is pushed, then configure it not to do that. From some quick Googling, it appears you can control the refs to be built, so you may want to configure it to just build refs/heads/*, which doesn't include tags.

Is there an ISubscriber event for completing a Pull Request in TFS 2018?

I am working on a plugin for TFS to hook certain operations. I'm able to successfully hook code pushes via using an ISubscriber on PushNotification, but am having trouble finding any type that matches up with the completion of a Pull Request.
A little more on what I'm trying to do. I currently have a PushNotification hook that has some branch specific checks that it does. Some reject a push, others provide notifications to users using some complex rules. I need a way to be able to provide the notifications at a minimum, and ideally prevent the pull request from going through. I can't provide notifications prior to the pull request going through as the notifications should only occur for code being placed in our main repository.
Long term, I want to switch it over to using the webhooks and some async approval, but I don't have the time to adapt the tools to work like that and setup the additional server needed to make that happen. If there's no good solution, I'll simply disable pull requests for now until I can write proper services for it, but if there is a way to reuse the adapted hooks that can run on the PushNotification ISubscriber, it would be extremely helpful.

Gerrit notification for commits without any action

In the Gerrit documentation there is no configuration setting, which could be used to automatically send emails if there was no action with a commit for a given period of time.
There is a notification type, abandoned_changes, but it means that the change was already abandoned.
What I want is an e-mail notification if the commit was not abandoned, but there was no action with it, like Hey, do you really need this commit?
You can't configure Gerrit to send this type of notification but you can search for open changes which are not updated for a while like in the following example:
is:open AND age:1week
See more info about search operators here.
You can make a script (bash, perl, etc) to execute the query using REST and send the result by e-mail.
See more info about query changes using REST here.

Jenkins. How to get Trigger builds remotely data from POST BODY

Jenkins. How to get Trigger builds remotely data from POST BODY
Quay.io (private docker containers registry) has notification about build status through Webhook POST, data is in body. I tried to google and read Jenkins docs, but found only how to read parameters from URL.
I found a plugin (Generic Webhook Trigger), which is capable to do it partially. It is able to work only with one link (http://{JENKINS_URL}/generic-webhook-trigger/invoke). And to start different jobs i need to use regexp.
At the same time i need to set up minimum 3 notifications on quay.io and a lot of webhooks from different services. Maybe somebody knows how to set up in Jenkins such stuff:
Create route like {JENKINS_URL}/jobName/ …
Take whole parameters and write it down into $POST_DATA variable.
Execute script with $POST_DATA parameter.
Another manipulations i’m able to do myself in script.
If you have a job like some-job-name.
Question 1:
Check the "Trigger builds remotely". Specify a token, like some-job-name.
Point the webhook to http://{JENKINS_URL}/generic-webhook-trigger/invoke?token=some-job-name .
Now this will be the only job triggered from this request.
Question 2:
Set the json-path to just $ and it will evaluate to the entire post data. Use any variable like variable.
Question 3:
Just use the variable from 2 like $variable.

Deploying to live server via link on email notification

I've been reading a few articles and watching a few videos on Jenkins. I'm wondering how easy it would be once the master branch has been deployed to a staging server to automatically send an email to the client notifying them of the url to the staging server and also giving them a link to "deploy live". This way the client can see the changes, make sure they're happy with it then deploy it themselves without having to email anyone requesting it to go live.
Anyone got any idea how easy this would be to do with Jenkins? There may be a plugin that does this but so far I've not come across anything.
I saw a talk where a guy does this to notify QA of a new build to test, as well as notify when a build is ready to be published to production.
Basically the last automated job (deploy to staging job) has a post build step to send an email to some address. The body of the email contains a link back to the REST API for the "deploy to production" job, triggering a build.
Email recipient tests things, and if satisfied, clicks the link and Jenkins runs the production job. Obviously this requires that the recipient has some kind of access to (at the very least, the REST API of) the Jenkins instance. That being said, there's no reason you couldn't set up your own system to take limited external requests and forward them to your Jenkins API.
The video link (including time reference of the relevant part) is: https://youtu.be/3HI7mv_791k?t=3169
If you've been watching a few videos you might have already come across it, but it's quite long so you might not have watched it all.

Resources