Skip to content

jenkinsci/cachet-gating-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cachet Gating Plugin

The Cachet Gating Plugin allows jobs to be held in the Jenkins queue based on Cachet resource availability.

Global Configuration

Before the plugin may be used, you must configure the Cachet API URL in the Jenkins global configuration:

Configuration as Code

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

Gating Jobs

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:

blocked job

Job setup using Job DSL

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"])
  }
}

Gating metrics

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 ""
}

Job setup using JJB

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