Issue
Jobs are being triggered on your instance and you are not sure why they are being built, or you would like to see if jobs are being automatically triggered or manually triggered by a certain user.
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
-
CloudBees Jenkins Enterprise - Managed controller
-
CloudBees Jenkins Enterprise - Operations center
Resolution
Within CloudBees Jenkins the cause of any Build for a particular job should be listed in the UI by navigating to said job and selecting the Build number in question from the left hand column.
For example the UI on the build page will show: Branch indexing
, Started by user $USER
.
However, if you would like to review all available builds on your instance in one aggregated output it’s possible using the below Groovy Script:
import hudson.model.Fingerprint.RangeSet import hudson.model.Fingerprint.Range Jenkins.instance.getAllItems(Job).each { it.getBuilds(new RangeSet(new Range(0,2))).each { build -> build.getCauses().each { println "[${ it instanceof Cause.UserIdCause ? cause.getUserId() : 'AUTOMATION'}] ${build}" } } } return
With this script any build triggered from automation such as polling/webhooks would begin with the tag: [AUTOMATION]
otherwise if triggered by a user each job input will begin with [$USER]