The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.
For a list of other such plugins, see the Pipeline Steps Reference page.
findJobs
: Job Finder list generatorMethod to find jobs based list of regular expressions for inclusions followed by exclusions. The return value will be the discovered list of jobs represented strings. Depending on how Jenkins is configured some of these jobs may be inaccessible.
Example:
findJobs( includes: [ "^some/path/one$", "^some/path/two$", ], excludes: [ "^.*ignore/Me.*$" ] )
includes : Array / List of String
(optional)
excludes : Array / List of String
(optional)
getAllLabelsForAllNodes
: Get All Jenkins Nodes and LabelsThis method provides the node to list of node labels
Example:
def audit=getAllLabelsForAllNodes(); def keys=audit.keySet(); for( String key : keys ) { echo "Node: ${key}" for( String label : audit[key]) { echo " Label: ${label}" } }
getCurrentBuildHost
: Get the Build Hostname in contextThis method returns the name of the current build host from Jenkins. This method exists because of the dind or Docker inside docker hostname delema.. and the "Who's hostname is this really problem it creates". Often times this is required when building system packages for red-hat or Debian, the build node hostname is typically a required argument for the build tools. This will return the same value. Notes about this method:
This method has 2 use cases:
1. In the pre-pipeline it will return the hostname of the Jenkins controller 2. When running in a stage on an agent it will return the hostname of that agent.
getLastSuccessfulBuildNumber
: Job build number getterProvides the last successful build number ( if any ) for a given job.
job : String
(optional)
relatedJobChecks
: Related Job ChecksTakes a list of related job paths: deps, and an optional boolean flag(s). The sanity check operations are run against all jobs that are listed, any job that fails these checks will cause this build to halt by throwing an exception. To disable a sanity check, set the option to false.
1. jobExists: If any of the jobs are null: throws exception halts the job as FAILED. 2. isBuilding: If any of the jobs are building: thows exception and halts the job as ABORTED. 3. inQueue: If any of the jobs are in the Queue: throws exception and halts the job as ABORTED. 4. isSuccess: If any of the are not in state success: throws exception and halts the job as ABORTED. 5. hasRun: If any of the jobs have never built throws an exception and halts the job ABORTED.Example:
relatedJobChecks deps: ['path/to/job','path/to/another/job'], // all of these are optional ( default is always true ) jobExists: true, // fails if the a job has never run isBuilding: true, // aborts if the job is building inQueue: true, // aborts if the job is in que hasRun: true, // aborts if the a job has never run isSuccess: true // aborts if the last jobs is not in a state of success
deps : Array / List of String
hasRun : boolean
(optional)
inQueue : boolean
(optional)
isBuilding : boolean
(optional)
isSuccess : boolean
(optional)
jobExists : boolean
(optional)
Please submit your feedback about this page through this quick form.
Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?
See existing feedback here.