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'?
-
The only way at the moment is to download the JavaDoc artifact of the Operations Center Context Plugin following the Custom Plugins: APIs and Javadocs of CloudBees Jenkins Enterprise plugins. You should find `RemoteRunWrapper` doc in there.
0
Please sign in to leave a comment.
Comments
1 comment