Reputation: 9785
I have 2 Jenkins hosts, and would like First Jenkins to trigger a job on remote Jenkins based on "SUCCESS" in result on the first one. I have looked at various plugins , but they all seem to indicate ONE Jenkins host, where multiple jobs can be chained in this manner.
Upvotes: 12
Views: 35026
Reputation: 1998
Cloudbees supports triggering remote jobs via their Operations Center plugins.
As of operations-center-context version 1.8.0, it is possible to trigger remote jobs from a Pipeline job using the ad-hoc Remote Trigger Job function. The RemoteTriggerJob step will appear in the list of available steps of Pipeline if operations-center-context (v. 1.8.0 +) plugin is installed in the Jenkins Instance.
Example usage in declarative pipeline:
triggerRemoteJob mode: trackProgressAwaitResult(
scheduledTimeout: [timeoutStr: '10 minutes'],
startedTimeout: [timeoutStr: '10 minutes'],
timeout: [timeoutStr: '40 minutes'],
whenFailure: stopAsFailure(),
whenScheduledTimeout: continueAsUnstable(),
whenStartedTimeout: continueAsUnstable(),
whenTimeout: continueAsUnstable(),
whenUnstable: continueAsUnstable()),
parameterFactories: [
[$class: 'SimpleString', name: 'MY_STRING_PARAM', value: 'Something-important'],
[$class: 'SimpleString', name: 'OTHER_STRING_PARAM', value: 'more-important-words']],
remotePathMissing: continueAsUnstable(),
remotePathUrl: 'jenkins://jenkins_instance_id/path_to_job'
Note: Parameterized Remote Triggers is a Tier 3: community plugin and is not supported by Cloudbees. https://docs.cloudbees.com/plugins/ci/Parameterized-Remote-Trigger
Upvotes: 0
Reputation: 11
Step 1: Install following plugins in both Jenkins.
Step 2: Configure job to be triggered(Jenkins B).
Select generic webhook trigger in build trigger and generate a token and paste.
After saving this job can be triggered by sending a http request to http://JENKINS_B_URL/generic-webhook-trigger/invoke?token=TOKEN_VALUE
Step 3: In master Jenkins(Jenkins A) configure flexible publish settings in configure system to allow use all build steps as post build actions.
Step 4: In post build actions add another step “Flexible publish”. Using this any build action can be used as post-build action. Add a HTTP Request action. Provide Jenkins B webhook url in url field and save.
Upvotes: 1
Reputation: 1626
It's very easy to do using cURL requests, no need for plugins or master>slave relations. It took me 5 minutes from beginning to start. Use the following manual:
https://www.nczonline.net/blog/2015/10/triggering-jenkins-builds-by-url/
Upvotes: 3
Reputation: 815
Meanwhile, a jenkins plugin became available which makes it a lot easier:
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Remote+Trigger+Plugin
Upvotes: 10
Reputation: 18528
Yes. Configure your Jenkins nodes and label them, say master
and slave
(Manage Jenkins -> Manage Nodes).
1) Configure Job A
and specify that it can only run on master
("Restrict where this project can be run" and in the label field put master
).
2) Configure Job B
so that it is only triggered if Job A
is successful:
"Post-build Actions" -> "Trigger only if build succeeds"
3) Pin Job B
to slave
similar to step 1.
Upvotes: -3