We would like to analyze the build history in a Jenkins job. We don't want to approve any dangerous signatures, so the logic should be implemented as a step in a Jenkins Shared Library. We use folders and multibranch jobs, so the mechanism has to analyze items recursively.
How to implement it?
To collect all builds the following code could be used.
It returns for every build:
<folder>/<job>/<branch name|PR number>
)branch name|PR number
)SUCCESS
,FAILURE
etc.)java.util.Date
)long
)If for example only builds executed within 24 hours must be executed, two approach could be used:
The second option is better because it doesn't force the logic to iterate through old builds.