Defined Type: jenkins::job

Defined in:
manifests/job.pp

Summary

Manage Jenkins jobs given a name and config xml

Overview

Parameters:

  • config (String)

    The content of the jenkins job config file (required)

  • source (Optional[String]) (defaults to: undef)

    Path to a puppet file() resource containing the Jenkins XML job description. Will override ‘config’ if set

  • template (Optional[String[1]]) (defaults to: undef)

    Path to a puppet template() resource containing the Jenkins XML job description. Will override ‘config’ if set

  • jobname (String) (defaults to: $title)

    the name of the jenkins job

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    choose ‘absent’ to ensure the job is removed

  • difftool (String) (defaults to: '/usr/bin/diff -b -q')

    Provide a command to execute to compare Jenkins job files

  • replace (Boolean) (defaults to: true)

    Whether or not to replace the job if it already exists.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'manifests/job.pp', line 13

define jenkins::job (
  String $config,
  Optional[String] $source                  = undef,
  Optional[String[1]] $template             = undef,
  String $jobname                           = $title,
  Enum['present', 'absent'] $ensure         = 'present',
  String $difftool                          = '/usr/bin/diff -b -q',
  Boolean $replace                          = true
) {
  include jenkins::cli

  Class['jenkins::cli']
  -> Jenkins::Job[$title]
  -> Anchor['jenkins::end']

  if ($ensure == 'absent') {
    jenkins::job::absent { $title:
      jobname => $jobname,
    }
  } else {
    if $source {
      $realconfig = file($source)
    }
    elsif $template {
      $realconfig = template($template)
    }
    else {
      $realconfig = $config
    }

    jenkins::job::present { $title:
      config   => $realconfig,
      jobname  => $jobname,
      difftool => $difftool,
      replace  => $replace,
    }
  }
}