Sam
Sam

Reputation: 41

Jenkins delay job delay for certain time between the Job A and B

I don't understand what exactly period is doing. When trying to use it nothing happens.

I have a build job which generates a binary and down the line two downstream projects that are called Job A and Job B and I want to have a delay between A & B - Job B needs to start 10 minutes after Job A completes.

Any condition to trigger parameterized build or build after other projects?

Thanks for your help!

Upvotes: 0

Views: 2881

Answers (2)

Dositej
Dositej

Reputation: 114

Answer provided by vivekyad4v should work. Bear in mind that he said that action should be added in the build section.

If you don't want/can't use Shell, you can simulate the wait by executing a Windows batch command. It's also located in the build step section, not the post-build.

For example:

ping 127.0.0.1 -n 30 

This command would ping localhost (127.0.0.1) 30 times, approximately 1 ping per second, accounting to 30 seconds in total.

For a full set of options ping can provide just call ping locally in your cmd and check out what you need. You can run the example command locally as well, and play around with it before injecting it to Jenkins .


So, if I understood the organization of your jobs correctly, you would want:

  1. Run the job which builds the binaries
  2. Run the job A "Testing", and all the necessary post-build actions
  3. Run the job B "Validation", which has the simulated wait for 10 minutes via ping as the first build step (Execute Windows batch command), in your case ping 127.0.0.1 -n 600, after which the rest build steps are executed; along with the post-build actions.

[edit 22.01.2017: changed the body of the ping command. initially it was pinging 1.1.1.1 which would result in ping Request timed out, potentially marking the Jenkins build as a failure, even though the wait period would be correct]

Upvotes: 1

vivekyad4v
vivekyad4v

Reputation: 14843

Currently, there is no option to set delay for a downstream job in post build actions.

Alternatively, you can achieve this by adding sleep 600(Shell) at the end of your build step of job A.

Upvotes: 1

Related Questions