Do BitBucket hooks fire on branch commits? - bitbucket

If I have multiple branches in my BitBucket repository, and push changes to one of the branches, do the hooks fire?
I want to ensure that my hook to AppHarbor only fires on pushes to the master, but I can't find any configuration on whether that is possible.

From what I can tell, they do.
However, with AppHabor, I can now attach to a specific branch in the repository. When done this way, only changes to that branch cause AppHarbor to get the updates and republish my website.
So I now have 3 "permanent" branches...
"dev" that I can push to any time and is not monitored by AppHarbor
"uat" that I pull from "dev" when desired, and this updates my UAT web site
"live" that I pull from "uat" when desired, and this updates my Live web site

Related

Limit pull request from a specific branch to target branch - BitBucket

My team is using BitBucket for Git repositories. We plan to go live in next two months and what I want to do is to limit so that the pull requests can be only made from a specific branch to the 'production' branch.
I am aware of the Branch Permission sections of the BitBucket but that solves by limiting the 'Changes without a pull request' only half the issue.
What I want to achieve is that there should be no changes allowed without approved pull request and this pull request can only be made from a specific branch.
If the pull request is made from any other 'random' branch to the 'production' branch the pull request could get automatically denied.
Is such a thing possible? Thanks.

How can we trigger gitlab-ci before pushing to repository?

I want to implement pre-receive hooks on the GitLab server side but we don't have access to the file system. Is there any way I can handle it with GitLab-ci? I want to get control over what can and can't be pushed to the repository.
One possible workaround would be for developers to:
push to a gateway repository
pull from an official one.
(both on GitLab)
You can then associate a job on the first one, on push:, in order to validate what has been pushed.
If validated, the job push the commit to the second official repository.
It's possible to implement pre-recieve hooks in gitLab but that comes when we have access to file system. For now, I have added gitlab-ci that will check on every merge request on protected branches and let all developers push to temp branches.

Trigger building the Github's webhook head_commit in Jenkins

I have configured a Jenkins Pipeline that correctly receives webhooks push notifications from GitHub, on push events.
The authentication is done through a deployment key.
Jenkins configuration seems to rely a lot on the concepts of branches and pull requests.
Given my workflow, which consists mostly of creating branches for any needs, and merge changes back onto master once things would look fine on the CI, I do not really care about seeing my builds categorized by branch or PR.
I would prefer to see builds based on commits' hashes. I do not see the need to tell Jenkins what branch I want it to match.
My current configuration is not selecting the commit revision I desire. I do not understand how it decides which branch or commit to build, once it receives a push notification. In Jenkins I have set the branch to **.
Checking the webhook payload, I noticed that it contains both the list of commits but also something called head_commit, with its id property being the commit's hash I want to see being built.
I would like Jenkins to do the following:
Check what's the head commit in the webhook notification (head_commit.id in the payload)
Build that precise commit, no matter the branch it is part of
Setting a green tick or a red cross beside the commit's hash on Github
Is this possible?

Branch permissions bypassed on Bitbucket: Pull request requires approval, but merges anyways?

We plan to have only admins able to make changes to our repo’s master branch. Developers can clone the repo and then create their own dev branch off of master to work on. When developers feel ready, they can merge their development branch onto the master branch using a pull request. However, they will not be able to merge their dev branch into master until the admins have approved the changes.
On Bitbucket, I set branch permissions as:
+ Write Access: Rachel and Jamie.
+ Merge via pull request: Rachel, Jamie, and team:developers.
+ Merge checks: check for at least 2 approvals.
Next, we had a developer (not Rachel or Jamie) make changes on their own dev branch. They then committed and pushed the changes to their remote dev branch--worked as expected.
Last, they initiated a pull request to merge the remote dev branch into master. A warning that two approvals was needed popped up, but the developer was still able to just click "Merge" and the dev branch merged into the master branch, despite 0 approvals.
I expected that the developer would not be able to merge with 0 approvals. How do I set permissions so that this is the case?
Two things:
You explicitly granted "merge via pull request" access to the developers. They're therefore able to merge pull requests. If you never want them to merge PRs to that branch, then revoke that. (They'll still be able to create PRs, just not merge them.)
You didn't mention whether you've enabled "Prevent a merge with unresolved merge checks", under the premium features.
We've created a plugin to prevent this situation. You can inspect it on marketplace:
https://marketplace.atlassian.com/apps/1219882/prevent-merge-when-needs-work

Build Jenkins project on BitBucket pushes and pull requests

I have a scenario where I'm setting up Jenkins for my app. I have BitBucket set up and firing appropriate webhooks.
I want to start a build whenever a push is made to the repo as well as whenever someone creates/updates a pull request.
I've looked at the BitBucket Plugin. It works good if I have the BitBucket webhook to fire for all pushes.
Then I added the BitBucket Pull request plugin to build on every pull request create/update. So I changed the BitBucket webhook preferences to fire on pushes and PR creates/updates.
Unfortunately, these plugins have conflicting settings, hence they cannot be used at the same time (as per my research, the minute I send custom webhooks from BitBucket, the first one stops working, but the second one works)
Has anyone been able to set this up correctly? Maybe there's a plugin for what I want, but I couldn't find it.
I want to keep writing a proxy in front of Jenkins to manage webhooks the last option, only if there really is nothing I can do.
Thanks for the help!

Resources