Reputation: 1091
I have several jobs running periodically on Jenkins. They are set up using the graphical interface:
Now I need to write a script that will pull information about when/how often does job run. How can I find this information?
I tried looking for this information using Remote Access API in XML, but to no avail.
Edit: Because some people find it hard to read such a short post, I would like to point out that I'm asking(literally) How to check how often is Jenkins building job? for script. Question means more or less how to get cron schedule for the job, not how to get Build number + Status[success/failed etc] + Duration from Jenkins.
Honestly, I can't see how one could even think that these are duplicates.
Upvotes: 0
Views: 1616
Reputation: 2340
Here you go:
SCHEDULE=$(cat ${JENKINS_HOME}/jobs/${JOB_NAME}/config.xml | grep -A 1 ' <hudson.triggers.TimerTrigger>' | tail -1 | awk -F'[<>]' '{print $3}')
if [ -z "${SCHEDULE}" ]; then
echo "${JOB_NAME} isn't configured to run periodically"
fi
You need access to filesystem on which Jenkins has it's home.
If this approach does not suit you - you can use token authentication or password/LDAP/whatever to download the job config xml to your working directory and parse it the same way. This might be helpful if you decide to do so.
Upvotes: 1