import groovy.json.*
stage("run salt") {
node("agent1") {
saltresult = salt authtype: 'pam', clientInterface: local(arguments: '"sleep 300; tail -1 /etc/hosts"', blockbuild: true,
minionTimeout: 32, function: 'cmd.run', jobPollTime: 7, target: 'master', targetType: 'glob'),
credentialsId: 'b5f40401-01b9-4b27-a5e8-8ae94bc90250', servername: 'http://localhost:8000'
def prettyJson = JsonOutput.prettyPrint(saltresult)
println(prettyJson)
}
}
getContext().newBodyInvoker().withContext(<run api call here>).withCallback(BodyExecutionCallback.wrap(getContext())).start();
But I am now stuck on how I should go about setting up finished(), start(), stop(), or onResume() methods. Basically, I think I understand how to start my communication with the saltapi, but I don't understand how the callback process works that I can somehow notify jenkins when the long running job polling returns something.
You may not use `newBodyInvoker` on a step that does not take a body
(~ closure argument).
Did you look at `SleepStep` for an example? Or `InputStep`?
`StepContext` has methods to let you return a value or throw an error.
`StepContext` has methods to let you return a value or throw an error.
> Do you mean the StepContextParameter
No, what I said:
http://javadoc.jenkins.io/plugin/workflow-step-api/org/jenkinsci/plugins/workflow/steps/StepContext.html#onSuccess-java.lang.Object-
> I did notice it wasn't working with the 2.3 version that I
> upped to.
I am not aware of any such bug.
@StepContextParameter
new Thread("saltAPI") {
@Override
public void run() {
try {
callRun(token, saltFunc, netapi);