How to automate creation of Tags on BitBucket from Jenkins using WebHooks? - jenkins

Is there any way to to support automatic tag creation on Bitbucket via Jenkins pipeline?
I know how to build a branch a Tag is created or a push is done to the repo.

You can use the Git Publisher addon in the Post-build Actions to do this. It does a lot more than just auto pushing tags but that is what I use it for. Right now, I have it set to push the build number as a tag to the branch that is being used.

Related

Jenkins not triggering build on PR merged in bitbucket

We are using Bitbucket cloud to host our repos and Jenkins for CI/CD.
I have setup a multibranch pipeline which has develop and release branches. I want to trigger develop branch whenever a PR is merged from the feature branches to develop a branch (In fact on any manual webhook edit).
Below are the cases I tried:
Setup Manage hook in Jenkin:
This creates a webhook in bitbucket and when PR is merged, build is triggered.
But when I disable the Repository Push option in the webhook, the build is not triggering on PR merge.
Setup the webhook manually:
In this case, the Jenkins logs show the branch name as PR-XY since not triggering the develop branch.
I have set up a regex to filter branches (only develop and release are allowed) and when I add regex like PR(.*) then build gets triggers from the PR section (not desired case).
I want the build to be triggered from the develop branch, not as the PR branch. I have followed most of the options available in the forums but it's not working. Any help regarding this will be appreciated.
I faced the same issue, it's look like most of jenkins plugins like bitbucket plugin does not trigger the pipeline on merge only. even though i set the bitbucket trigger options like this:
unless you add a check mark next to push option.
to solve this i used another Jenkins plugin called Bitbucket Push and Pull Request
just make sure to uninstall Bitbucket plugin if you have it.
so you can use this one as they mentioned in there docs.
and follow the setup instructions.
note: i only test it with normal pipeline job

Create a pull request using Jenkinsfile

I'm using Bitbucket as a git management repository solution, and I want automatically create PRs, when my feature branches builds are successful.
So, is there any way to set this up with a Jenkinsfile?

create github pull request from a jenkins pipeline job

I want to create a PR to my git repository from a jenkins pipeline.
I know it's a bit revers flow than the general flow where we trigger jenkins job based on PRs.
But in my case, user will manually trigger a job & I will create clone an existing git repo. After that, will update some files (via the same job pipeline). And then I want these changes to be pushed to my github repo & have a PR ready to be reviewed by the devs.
Is there any way to do this ?
I am trying around hub but want to know if there's any other way of achieving this?

Trigger Jenkins build via push to a specific branch on GitLab

If there is the way to trigger Jenkins build via push to a specific branch on GitLab. At this moment I am using GitLab webhooks integration, to run a specific job? Now it starts after the push to any branch, but I need to start a job from push to the specific branch.
It's now possible since Gitlab 11.3 (https://about.gitlab.com/2018/09/22/gitlab-11-3-released/)
Does not appear to be possible currently by selecting a branch in the GitLab webhook. Feel free to watch progress on this new feature in the GitLab issue Filter web hooks by branch.
I did note in the issue comments the following that might help you configure things via Jenkins:
Jenkins GitLab plugin has an option to filter WebHooks by branch. Under Build Triggers --> Build when a change is pushed to GitLab --> Advanced...

Github Jenkins plugin with Github Enterprise

I have a Jenkins server with the following github plugins:
github-api
github
github-pull-request
I want to trigger a build after a merge (from a PR). This is because I have some build chains that I don't execute when building a PR so after a merge I need to create new deployment packages.
In the enterprise github there doesn't seem to be the same interface (as regular github) for webhooks I don't seem to be able define what events the github plugin (webhook) should listen for so I think its just the default 'push' event. Is this done somewhere else or is it a limitation of the enterprise version?
UPDATE
I have the github plugin working now but its builds for every push if I check the box. This disucssion https://groups.google.com/forum/#!topic/jenkinsci-users/gew5gWVDxw8 suggests that I should be able to use the git scm and github plugin together. Github plugin will register a change, scm plugin will poll server to determine if this change was tho the watched branch. I also tried this suggestion How can I make Jenkins CI with git trigger on pushes to master?
When I try and configure this no branch is ever built!
At least for me it's not exactly clear from your question what you actually exactly want.
It sounds like you only want builds to be triggered if there are some new commits on github on a specific branch.
If this is all you're looking for, you can just setup a webhook (Jenkins (Github Plugin)).
In you Jenkins job, just specify the branch you're tracking (Branches to build).
Assuming you setup github's hoock to jenkins correctly, this should trigger your build job on each commit on github enterprise.
If your hook doesn't seem to work: To check if and what your github server actually would send to your jenkins server, you can temporarily replace the url to your jenkins server in github's webhook with something like requestb.in (this will let you inspect github's hook payload)

Resources