Reputation: 165
I have a jenkins job currently and I'm trying to set it to run every 4 hours via a jjb. I've configured it to run every 4 hours currently by manually editing the job and selecting the "Build Periodically" trigger and entering in the appropriate value. However, i'd like to find a way to automate this process. I've looked through the documentation here: https://media.readthedocs.org/pdf/jenkins-job-builder/latest/jenkins-job-builder.pdf
but I haven't had any luck.
This is what I have currently:
- 'build-job-jjb-{type}-{label}':
type: build
label: Build
git_repo: XXXXXXX
git_url: [email protected]:XXXXXXXX/{git_repo}.git
git_branch: origin/develop
home: pipeline/scripts
cmd: ./build.sh
triggers:
- timed: "00 08,12,16,20,00,04 * * *"
Upvotes: 1
Views: 1148
Reputation: 51
You are on the correct way, but you could set a schedule like:
-job:
triggers:
- timed: "0 */4 * * *"
This execute your job every 4 hours at minute 0.
If you want to let the server choose the minute when the load is low, you should set:
-job:
triggers:
- timed: "H */4 * * *"
This worked for me, and I've created the job with jjb template .
I hope this help you!
Upvotes: 5