How to trigger multiple builds on a gerrit commit? - gerrit

I have gerrit project integrated with Jenkins Server.
When i push a commit into gerrit then a jenkins build is triggered for windows OS(configured parameter) only. Now i want the gerrit to trigger a build on linux OS as well.
So how do we configure such that a commit into gerrit triggers two builds one on Windows OS and the other one on Linux OS ?
Could anyone suggest on how to achieve this ?

You should set the Gerrit trigger pulugin in your job in Jenkins. You can read more detail on this link: https://wiki.jenkins.io/display/JENKINS/Gerrit+Trigger
Actually this plugin checks the Gerrit events so you can trigger many job with one commit. I use this Plugin to trigger more jobs in Jenkins and it works as expected.

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

How to trigger a jenkins job whenever some changes are pushed to gerrit server

I have to trigger a jenkins job whenever a new patchset is created, that is whenever some changes are pushed to a specific project and specific branch in gerrit server it should trigger that jenkins job.
I have installed the Gerrit plugin in jenkins, gerrit version is 2.16.5.
It seems some configuration is needed to be done but I do not know as I am new to Jenkins and Gerrit.

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...

How to trigger jenkins Job on code pushed to development server?

I have development code repository at bitbucket and another test script code repository at bitbucket. Now I have setup a Jenkins job by linking test code repository. Is there any way to trigger jenkins job automatically on change in development repository ?
You can add the BitBucket Plugin to your Jenkins instance. It will allow you to configure a webhook in BitBucket that will then trigger any Jenkins job listening for that webhook. The plugin's page has a detailed breakdown, but the basics are;
In your repo in BitBucket, create a new Webhook using your Jenkins' url. I believe the url is generally http://[your jenkins url]/bitbucket-hook/
Make the trigger a repo push.
In your Jenkins job, check the box "Build when a change is pushed to BitBucket" under the Build Triggers section.
Now any time you commit to the repo you created the Webhook on, that Jenkins job will be run.
You can also limit what branches trigger commits by parameterizing your Jenkins build to ignore certain branches / keywords / etc if that's something you need for your specific project.
Builds by source changes
You can have Jenkins poll your Revision Control System for changes. You can specify how often Jenkins polls your revision control system using the same syntax as crontab on Unix/Linux. However, if your polling period is shorter than it takes to poll your revision control system, you may end up with multiple builds for each change. You should either adjust your polling period to be longer than the amount of time it takes to poll your revision control system, or use a post-commit trigger. You can examine the Polling Log for each build to see how long it took to poll your system.
Alternatively, instead of polling on a fixed interval, you can use a URL trigger (described above), but with /polling instead of /build at the end of the URL. This makes Jenkins poll the SCM for changes rather than building immediately. This prevents Jenkins from running a build with no relevant changes for commits affecting modules or branches that are unrelated to the job. When using /polling the job must be configured for polling, but the schedule can be empty.

How to catch changes in Gerrit Repo from Jenkins and build the project on change?

I have setup project to build Gerrit based android ICS source from Jenkins using Gerrit Repo. It builds source successfully.
Now, i want to make some changes in my Android source on any branch of Gerrit. How can I detect those changes from jenkins and trigger a build for every changes i merged in gerrit based android source automatically without any manual intervention ?
Is Gerrit Trigger plugin useful for it ?, I have setup Gerrit Trigger in Jenkins Test connection works fine but when i made some changes in source the build is not triggered ?
Please, give the solution for it or any other option to catch changes and building source from jenkins ?
Thanks,
amar.
I´m not sure if i understand the question, but if you just want the build to to pickup changes made to a git repo, just configure a post-commit hook or poll the repo for chagnges in intervalls.
If you mean like changeing something in the gerrit to make a new commit, this can be what you looking for: Gerrit change-merged Hook

Resources