I have a freestyle (shell) jenkins job that in certain situations will checkout a different git tree than the one with which it was started. The reason behind this is procedural requirements.
The general flow is:
Questions:
lastBuiltRevision
?Please assume that several (not small, not large) number of job results are kept by jenkins but the job we are interested in might be overwritten. Workspace content is not kept and we prefer it to stay this way.
Notification of the external monitoring system from jenkins is not feasible. They are accessible but some additional data in the external system cannot be bound to the jenkins data. I need to get few additional bits of information to record in the audit log.
Any hints are greatly appreciated.
What is exactly recorded in
lastBuiltRevision
?
lastBuiltRevision
is the commit checked out by Git plugin when the build starts, i.e. it is the SHA1 of the commit pointed by the treeish configured in Branches to build field.
If this is the sha1 of the git_identifier passed as part of the build parameters how can i get the sha1 of the state of the checkout (detached head) after the build has completed?
lastBuiltRevision
might be the git_identifier but only, if you have configured $git_identifier
into Branches to build field.
Anyhow, if you check out another commit later on in a build step, Jenkins does not have any record on this: lastBuiltRevision
will stay in the revision originally checked out by the Git plugin.
If you want to record this information yourself, here are some options: