The Cachet Gating Plugin allows jobs to be held in the Jenkins queue based on Cachet resource availability.
Before the plugin may be used, you must configure the Cachet API URL in the Jenkins global configuration:
unclassified:
globalCachetConfiguration:
cachetUrl: https://example.com
ignoreSSL: false
Using multiple sources:
unclassified:
globalCachetConfiguration:
sources:
- cachetUrl: https://example1.com/foo
label: example1
- cachetUrl: https://example2.com/v1
label: example2
ignoreSSL: true
To gate jobs, in the job configuration check the box to confirm resource availability before building and then select the required resource from the list. Note that all selected resources must be available for the job to run.
Below is an example of a build that is blocked or gated:
You can also use the job dsl plugin to configure gating for your jobs. Here is an example snippet:
properties {
cachetJobProperty {
requiredResources(true)
resources(["service1", "service2"])
}
}
You can use the following Jenkins pipeline snippet to gather metrics once build has started after being gated:
def metricsMap = cachetgatingmetrics()
if (metricsMap.size() > 0) {
echo "Semaphore Required Resources Gating Metrics:"
} else {
echo "This build was not gated by required resources not being available"
}
metricsMap.each{ k, v ->
echo "- Resource name: ${k}"
echo "- Status: ${v.getGatingStatus()}"
echo "- Elapsed time: ${v.getGatedTimeElapsed()} ms"
echo ""
}
From jenkins-job-builder 2.10.2 you can setup your jobs using JJB. Here is an example snippet:
properties:
- cachet-gating:
required-resources: true
resources:
- beaker
- brew