I have a downstream jenkins job(B) which now gets triggered automatically by upstream job(A) if it is stable. But I want a manual trigger button in the pipeline view for job B. If job A is stable job B should wait for manual trigger to start. I'm using jenkins freestyle project for creating jobs.
First you have to remove the downstream jobs from A. Follow the steps and disable first.
#goto the job B
#configure
#goto build triggers and uncheck the button
build after other projects are built
So afterwards Job B will not get start automatically. And now you can goto your pipeline view and see and edit.
Related
Context: We have a Jenkins 2.361.3 server and a local Bitbucket server with webhooks (on Push) that trigger multibranch pipeline jobs (declarative jenkinsfile mode) on Jenkins for every repo push. This works fine when we have a single multibranch pipeline job on Jenkins: the build is triggered for the correct branch.
New scenario: We want a second 'nightly' multibranch pipeline job on the same Jenkins server for the same Bitbucket repo, which we want to trigger on a fixed time every day for every branch that exists at that time. It should not trigger for repo pushes.
Actions taken: We created a second multibranch pipeline job, similar to the first one but now with a cron trigger in the jenkinsfile and this setting disabled: "Build when a change is pushed to BitBucket":
This setting is still enabled for the initial job.
Expectations:
On a repo push, only the initial job is triggered. The nightly job does nothing.
When the cron time hits, the night job is triggered.
Actual:
On a repo push, both jobs are triggered. (also after Jenkins restart)
Additionally, the cron trigger works as expected.
Question: How to configure this system so that a repo push only triggers the initial job and not the nightly job?
It looks like the combination of BitBucket plugin (v223) and Multibranch Pipeline plugin (v716) does not adhere to the "Build when a change is pushed to BitBucket" setting.
Experiments performed:
Disabling the "Build when a change is pushed to BitBucket" setting for both jobs (and restarting Jenkins) --> both jobs are still triggered by a repo push
Remove the webhook from BitBucket and configure 'polling SCM' for both jobs --> this works but polling feels suboptimal and adds performance hits to the server.
We solved it using the “Suppress automatic SCM triggering” property in the ‘Branch Sources’ section of the Jenkins configure page for the job, as explained here.
The ‘Scan multibranch pipeline trigger’ setting only controls the scans (even though the text says ‘build’), and this will cause a trigger. The Suppress property lets a certain job ignore a webhook or scan trigger. And then the job is only triggered by its cron-trigger, which is what we wanted.
I am using the "P4 Plugin" - https://wiki.jenkins-ci.org/display/JENKINS/P4+Plugin in Jenkins v2.32.1.
I would like to trigger specific jobs in Jenkins, depending on what path is changed in SCM.
For example if something changes in
//depot/branchA
Build job A. If something changes in
//depot/branchB
Build job B.
As far as I can tell the plugin is only set up to trigger every job in Jenkins that has "Perforce triggered build." (building both A and B jobs) Am I missing something? I am currently using SCM polling and trying to move to a more efficient system.
This understanding is based on reading the "Triggering" section of https://github.com/jenkinsci/p4-plugin/blob/master/SETUP.md
You may be defining too broad a workspace, and causing Jenkins to trigger on every submit. The client workspace associated with job A should only map //depot/branchA/..., and the workspace for job B should only map //depot/branchB/....
Jenkins polls for changes, and if it sees any, triggers any build that has a matching path. So if both jobs had a workspace that mapped //depot/... then submits to branchA or branchB would trigger both jobs.
How can a job A trigger a job B, such that job B will poll its SCM and then decides wether the actual build would be started or not?
Here is my 'real world' setup: I have a job called GIT_PULL which is using Jenkins DSL to create child jobs depending on sub folders in the repository content. Those child jobs poll the SCM itself but with the option 'Polling ignores commits in certain paths' to ensure they were just triggered, when their sub path has changed.
The current state is that all the child jobs poll the SCM theirselves every H/5 minutes and run independently of their parent job GIT_PULL. However I need to know in GIT_PULL if after a SCM change all child jobs has run fine. But when I switch the polling in the child jobs off and trigger all child jobs in GIT_PULL, they will all run no matter if their repository sub paths has changed or not.
So how can I trigger all child jobs in GIT_PULL, waiting for their result and such that the child jobs will check SCM changes before they will actually run?
Yess - The Multijob Plugin will do the trick.
Within a MultiJob you can define downstream jobs to start but to Build only if SCM changes (that is the exact option name) occur in the downstream project.
I recently set up github pull request builder on jenkins and it works well when I commented the trigger phrase on the PR. But when I tried to run multiple jobs by setting the downstream upstream relationship, I met this problem which is jenkins triggered the job job A set up by pull request builder as normal, but wouldn't trigger the downstream job job B when job A has finished.
Here are some of settings:
In job A: just everything on the instruction page of the github pull request builder
In job B: Under Build Triggers section, I checked Build after other projects are built and set the projects to watch to be job A, and checked Trigger only if build is stable (Nothing about github pull request builder on job B)
Try doing this from the upstream project, instead. From the upstream project configuration, Add post-build action --> Build other projects, then enter the name of the project to build.
I want Jenkins to run a regularly scheduled build A only if another regularly scheduled build B has been successful. If the build A has failed the this way dependent build B should not run (since it would fail also).
I don't want to trigger B from A directly since B as a completely other schedule (runs more infrequently).
Try BuildResultTrigger Plugin - you can set it in job B to poll the results of job A with the desired (un)frequency.
I would recommend the Parameterized Trigger Plugin. As a post-build step on B, have job A be triggered on a successful build. You don't have to specify parameters.