bitbucket webhook to jenkins with branch name - api

i have a bitbucket repo that sends webhook to trigger jenkins job.
http://:8080/buildByToken/buildWithParameters?job=webhook_me&token=t
i want to send with the webhook the bitbucket branch name,
so i search the web for the right way to use Environment variables on bit bucket and i've found this site:
so i've edited the url with an "&branch=$BITBUCKET_BRANCH" at the end, but it won't work.
any ideas what should i do in order to send the webhook with the branch name?
*******EDIT*******
i saw that there is something called Bitbucket event payload.
which is a json that contains all of the details about the webhook:
https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html
but i can't figure a way how to use it and pull it's data from jenkins.
i think that, this is the way to solve this, but i don't know how to use it.

i've found a way to do it, it works for me.
you need to use the bitbucket plugin: Bitbucket Plugin
then inside the job you need to specify the branch that will trigger the job after a push and check the marked checkbox:
then on the bitbucket create a webhook with the following URL:
http://:/bitbucket-hook/ Like so:
then push something to this repository and that branch, and there you go!
if you try to push to a different branch, the job won't be triiggered

The $BITBUCKET_BRANCH is only available in the Jenkins job. You are just literally passing the text "$BITBUCKET_BRANCH as the "branch" parameter. You can't pass in an environment variable like that.
$BITBUCKET_BRANCH may simply be available in the job, depending on the version of Jenkins and type of job you are using. In a pipeline job, this would be easy to access (if you have the right version of things). You don't need to pass it in unless you are trying to give it some other branch. In that case, you will need to see if you can get the branch on the bitbucket side to pass in to Jenkins.

Have you tried using jenkins-like variable ${BITBUCKET_BRANCH} instead of $BITBUCKET_BRANCH which is more shell-like variable?

Related

How to import repo from gitlab into Phabricator via phab api?

I want to create a batch of Repository in Phabricator. These repo already created in gitlab, So i want to just export them into Phabricator via APIs. But i didn't find those APIs worked for this. i could do this manually via Phab UI, like this, while it is not efficient for batch of repository.enter image description here
Did you try diffusion.repository.edit? That should be suitable for creating the repositories. Then either use git to push the repository contents, or use diffusion.uri.edit to set all other URLs to read-only temporarily and add an "observe" URI pointing to the gitlab repository, then after everything is all synced, remove the gitlab URL and set the others back to read/write.

How to create an issue related to a pull request for a public Apache (or other) repository

As an open source Oozie newbie user, I found the need of improving a few line of its source code, thus I forked another Oozie repository for myself, created a branch for the fix, pushed my change to that branch, and then made a pull request for that: ( https://github.com/mapr/oozie/pull/1 )
But based on github document, a pull request should correspond to an ìssue. As the Apache (or Mapr) repository is public (https://github.com/mapr/oozie), I cannot create an issue in github. So I only created the issue in apache jira (https://issues.apache.org/jira/browse/OOZIE-2646)
But in practice, my created issue in Jira and my pull request have not linked to each other at all. Anyone has suggestion on this impasse?
The github repository is just a mirror, as shown by this screenshot:
So doing a pull request won't help. The correct way to submit a code change is explained here.

I want Bitbucket cloud merge button to trigger Bamboo cloud build

So I have builds being triggered by bamboo when there's a push to a branch using the Remote Trigger. This works perfectly.
However, I want the same thing to happen when I click the "merge" button on Bitbucket Server. The code merges into master but the build does not get triggered.
Is there a way to fix this?
You can use Http Request Post Receive Hook for this . https://marketplace.atlassian.com/plugins/de.aeffle.stash.plugin.stash-http-get-post-receive-hook/server/overview
For Bitbucket cloud,
You can select Create New Plan Branches for New Branches under Branches->'Automatic branch management'. I just tested it on Bitbucket and Bamboo cloud and it works perfectly.

How do I create GitLab CI jobs using the API?

I am looking for a way to trigger some GitLab CI jobs, on-demand from another service. Is this possible and if so, how?
Details: imagine that I need to trigger a complex build from an external process.
One workaround that comes into my mind if to have a job-scheduler.git repository that only contains .gitlabci.yml file that is rewritten each time I need to trigger a build. I put the code to be run there and that's it. Other ideas?
That seems to be the purpose of… triggers: https://gitlab.com/help/ci/triggers/README.md
you then have an api endpoint where you specify the project's id, the trigger token and the git ref.

why drone ci doesn't automatically build my repo after pushing commit?

I was trying self hosted drone CI and i have sample repository setup for this project.
I followed all the step to setup and it is able to show and pull the list of all my repo in github, but when i tried to make changes to drone repo nothing happen and it still show empty page with this message.
This will be your commit stream
Add a .drone.yml file and make a commit to trigger a build
I am running drone ci on virtualbox that comes with the Vagrantfile on the drone repo
If you configured everything properly, it may be a formatting problem with your .drone.yml. Drone does not give feedback on these errors and you have to check your webhook logs to discover the problem.
I'm assuming you have properly configured the webhook in your Github repo.
Use your browser to navigate to your Github repo, and select Settings tab.
Under settings, select Webhooks. You should find the webhook you configured to your self hosted Drone
Click on the specific webhook and at the bottom you can find the Recent deliveries section. This is a log of all events your repo has tried to communicate to Drone.
Check the response the Drone server sent you.