0

Triggering a downstream job in a different Jenkins instance, track the downstream job and do more with it.

Job type: Pipeline scripts.

The complete code below:

properties([
parameters([
string(name: 'var1', defaultValue: "value1", description: ''),
string(name: 'var2', defaultValue: "value2", description: ''),
string(name: 'var3', defaultValue: "value3", description: '')
])
])

node('unique tag'){

stage("Trigger downstream"){

//From Jenkins
def remoteRunWrapper = triggerRemoteJob(
mode: [$class: 'ConfirmStarted', timeout: [timeoutStr: '1h'], whenTimeout: [$class: 'StopAsFailure']],
remotePathMissing: [$class: 'StopAsFailure'],
parameterFactories: [[$class: 'SimpleString', name: 'var1', value: var1], [$class: 'SimpleString', name: 'var2', value: var2], [$class: 'SimpleString', name: 'var3', value: var3]],
remotePathUrl: 'jenkins://..',
)

print(remoteRunWrapper.toString())
//would want to use other capabilities offered by remoteRunWrapper
}
}


The 'triggerRemoteJob' is able to trigger the downstream job and return with an instance of 'RemoteRunWrapper' after the job has started. The 'RemoteRunWrapper' instance should provide capabilities that will allow me to check on the downstream job/retrieve logs. There is however no documentation on the 'RemoteRunWrapper' that I could find. The methods described in the 'RunWrapper' documentation (https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html) cannot be used and the script fails with the error:

'groovy.lang.MissingMethodException: No signature of method: com.cloudbees.opscenter.triggers.RemoteRunWrapper.getId() is applicable for argument types: () values: []'

How can I find the capabilities offered by 'RemoteRunWrapper'?

1 comment

Please sign in to leave a comment.