简体   繁体   中英

How to use “Parameterized Remote Trigger Plugin” in Jenkins Pipeline script?

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?

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

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM