Class: Jujube::Job

Inherits:
Object
  • Object
show all
Extended by:
Macros
Defined in:
lib/jujube/job.rb

Overview

Models a single Jenkins job.

Attributes collapse

Sections collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Macros

attribute, section

Constructor Details

#initialize(job_name) {|self| ... } ⇒ Job

Initialize the job.

Takes a configuration block for adding atributes and sections to the job. The configuration block is passed the new Job as a parameter.

Parameters:

  • job_name (String)

    The name of the job. Will be the name as seen in Jenkins.

Yield Parameters:

  • self (Job)

    Passes itself to the configuration block.



16
17
18
19
20
21
22
23
# File 'lib/jujube/job.rb', line 16

def initialize(job_name)
  @config = {}
  self.name = job_name

  yield(self) if block_given?

  self.class.register(self)
end

Instance Attribute Details

#block_downstreamBoolean

true if this job should block while downstream jobs are running.

See http://docs.openstack.org/infra/jenkins-job-builder/definition.html.

Returns:

  • (Boolean)


74
# File 'lib/jujube/job.rb', line 74

attribute :block_downstream

#block_upstreamBoolean

true if this job should block while upstream jobs are running.

See http://docs.openstack.org/infra/jenkins-job-builder/definition.html.

Returns:

  • (Boolean)


66
# File 'lib/jujube/job.rb', line 66

attribute :block_upstream

#concurrentBoolean

Returns:

  • (Boolean)


90
# File 'lib/jujube/job.rb', line 90

attribute :concurrent

#descriptionString

Returns:

  • (String)


50
# File 'lib/jujube/job.rb', line 50

attribute :description

#disabledBoolean

Returns:

  • (Boolean)


98
# File 'lib/jujube/job.rb', line 98

attribute :disabled

#nameString

The name of the job - will be the name as seen in Jenkins.

See http://docs.openstack.org/infra/jenkins-job-builder/definition.html.

Returns:

  • (String)


33
# File 'lib/jujube/job.rb', line 33

attribute :name

#nodeString

The Jenkins node or named group where the job should be run.

See http://docs.openstack.org/infra/jenkins-job-builder/definition.html.

Returns:

  • (String)


58
# File 'lib/jujube/job.rb', line 58

attribute :node

#project_typeString

The type of job. This normally does not need to be specified, as it will be inferred as matrix if any axes are added.

See http://docs.openstack.org/infra/jenkins-job-builder/definition.html.

Returns:

  • (String)


42
# File 'lib/jujube/job.rb', line 42

attribute :project_type

#quiet_periodFixnum

Number of seconds to wait between consecutive runs of the job.

See http://docs.openstack.org/infra/jenkins-job-builder/definition.html.

Returns:

  • (Fixnum)


82
# File 'lib/jujube/job.rb', line 82

attribute :quiet_period

Class Method Details

.all_defined_duringArray<Job>

Keep track of all Jobs defined during the execution of the passed block.

This is used during job loading so that no extra syntax is required in the job definition files for registering jobs and so that it is possible to create jobs for testing purposes without having them registered anywhere.

Returns:

  • (Array<Job>)

    Returns a list of all Jobs defined within the block.



230
231
232
233
234
235
236
# File 'lib/jujube/job.rb', line 230

def self.all_defined_during
  @registry = []
  yield
  @registry
ensure
  @registry = []
end

.register(job) ⇒ Object

Register a Job in a registry.

If no registry is active, this is a no-op.

Parameters:

  • job (Job)

    The job to register.



243
244
245
# File 'lib/jujube/job.rb', line 243

def self.register(job)
  @registry << job if @registry
end

Instance Method Details

#axesArray

The matrix axes for the job.

Add axes in the job's configuration block using helper methods defined in Components::Parameters.

See http://docs.openstack.org/infra/jenkins-job-builder/project_matrix.html.

Returns:

  • (Array)


118
# File 'lib/jujube/job.rb', line 118

section :axes

#buildersArray

The builders for the job.

Add builders in the job's configuration block using helper methods defined in Components::Builders.

See http://docs.openstack.org/infra/jenkins-job-builder/builders.html.

Returns:

  • (Array)


184
# File 'lib/jujube/job.rb', line 184

section :builders

#notificationsArray

The notifications for the job.

Add notifications in the job's configuration block using helper methods defined in Components::Notifications.

See http://docs.openstack.org/infra/jenkins-job-builder/notifications.html.

Returns:

  • (Array)


206
# File 'lib/jujube/job.rb', line 206

section :notifications

#parametersArray

The parameters for the job.

Add parameters in the job's configuration block using helper methods defined in Components::Parameters.

See http://docs.openstack.org/infra/jenkins-job-builder/parameters.html.

Returns:

  • (Array)


129
# File 'lib/jujube/job.rb', line 129

section :parameters

#propertiesArray

The Properties for the job.

Add properties in the job's configuration block using helper methods defined in Components::Properties.

See http://docs.openstack.org/infra/jenkins-job-builder/properties.html.

Returns:

  • (Array)


140
# File 'lib/jujube/job.rb', line 140

section :properties

#publishersArray

The publishers for the job.

Add publishers in the job's configuration block using helper methods defined in Components::Publishers.

See http://docs.openstack.org/infra/jenkins-job-builder/publishers.html.

Returns:

  • (Array)


195
# File 'lib/jujube/job.rb', line 195

section :publishers

#scmArray

The SCMs for the job.

Add SCMs in the job's configuration block using helper methods defined in Components::Scm.

See http://docs.openstack.org/infra/jenkins-job-builder/scm.html.

Returns:

  • (Array)


151
# File 'lib/jujube/job.rb', line 151

section :scm

#to_hObject

Generate a Hash repsentation of the Job.



216
217
218
219
# File 'lib/jujube/job.rb', line 216

def to_h
  infer_project_type
  {'job' => config}
end

#to_yaml(*args) ⇒ Object

Generate a YAML representation of the Job.



211
212
213
# File 'lib/jujube/job.rb', line 211

def to_yaml(*args)
  to_h.to_yaml(*args)
end

#triggersArray

The triggers for the job.

Add triggers in the job's configuration block using helper methods defined in Components::Triggers.

See http://docs.openstack.org/infra/jenkins-job-builder/triggers.html.

Returns:

  • (Array)


162
# File 'lib/jujube/job.rb', line 162

section :triggers

#wrappersArray

The wrappers for the job.

Add wrappers in the job's configuration block using helper methods defined in Components::Wrappers.

See http://docs.openstack.org/infra/jenkins-job-builder/wrappers.html.

Returns:

  • (Array)


173
# File 'lib/jujube/job.rb', line 173

section :wrappers