Hi, I'm a Jenkins noob here, may I ask if there is a way for me to get the build trigger type (manual or auto) of the current build and the update status of the working copy like in the image above (no change or there are commits) in the Groovy script, so Jenkins can skip the auto build if there is no change?
Thanks a lot.
CodePudding user response:
There are multiple good answers to your first question here. One suggestion is to use:
currentBuild.getBuildCauses(<cause>)
Another is to use
triggeredBy cause: '<cause>'
As for the number of commits, you could simply use git commands to get the number of commits between the existing, checked out repo and the repo in the remote, or you could do it via Jenkins. Here is a gist that should be able to help.
CodePudding user response:
You can use the following groovy snippet to get the number changes.
if(currentBuild.changeSets.size() > 0) {
// Chnages are present
}
As MB mentioned you can do currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
to get manual triggers.