I need to run a bash script in a remote vm (not a jenkins node) and check the status and fetch the stdout to jenkins so I can trigger some other pipelines.
I have tried external-monitor-job plugin but remote vms don't have access to jenkins thus this is not an option.
I want to create a pipeline that runs a bash script in the background and another job to check if this process is finished via it's PID. Bash script will run for quite a while so I cannot keep the jenkins node busy for the whole time so I came up with the following idea.
Yes : Fetch the output.logs
No : Schedule job 2 for 10 minutes later
How can I schedule the build to run 10 minutes later ?
Thanks to the internal structure of the execution of a pipeline, you can execute out of a node (i.e. directly on the master). You can then execute your pipeline but put a sleep
before pipeline
or node
. It would give something like that
sleep(time:10,unit:'MINUTES')
pipeline{
agent any
//do your stuff
}