5

I tried search but didn't find any example. I tried https://jenkins.io/doc/pipeline/examples/#trigger-job-on-all-nodes and got it is for the different nodes on the same Jenkins. I would like to trigger a build on another Jenkins. I configured the Remote Hosts and Authentication in system configuration of my Jenkins. How to call "Parameterized Remote Trigger Plugin" in Jenkins Pipeline script?

2 Answers 2

7

Seems to be an open bug: https://issues.jenkins-ci.org/browse/JENKINS-38657

As a workaround you could create another job locally of an old type and use the plugin in the old school non pipeline script way. Then in your pipeline script you would just trigger this job. I know it's an ugly adapter but then you have parametrize this adapter and have it up and running for almost anything ;)

EDIT:

The bug 38657 is already closed, the plugin is available as pipeline step since 16th of May 2018. Usage should be as easy as:

//Trigger remote job def handle = triggerRemoteJob(remoteJenkinsName: 'remoteJenkins', job: 'RemoteJob') 

More information on the triggerRemoteJob step

Sign up to request clarification or add additional context in comments.

Comments

6

For anyone wondering how to do this using the Declarative Jenkinsfile Syntax:

steps { triggerRemoteJob remoteJenkinsName: 'configured-remote-jenkins-name', job: 'trigger-job-folder/trigger-job-name', blockBuildUntilComplete: true } 

2 Comments

how do you pass a user token with that?
@kayleeFrye_onDeck For the token, you would need something like this: import hudson.util.Secret ... def buildResult = 'org.jenkinsci.plugins.ParameterizedRemoteTrigger.pipeline.RemoteBuildPipelineStep'( remoteJenkinsUrl: "the_url", job: "the_job", parameters: 'MY_PARAM=value', auth: TokenAuth(apiToken: Secret.fromString("the-token"), userName: "username") )

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.