Class: Jenkins2::API::Job::Proxy
- Inherits:
-
ResourceProxy
- Object
- ResourceProxy
- Jenkins2::API::Job::Proxy
- Includes:
- RUD
- Defined in:
- lib/jenkins2/api/job.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Attributes inherited from ResourceProxy
Instance Method Summary collapse
-
#build(build_parameters = {}) ⇒ Object
Schedule a job build.
-
#copy(from) ⇒ Object
Create a new job by copying another one.
-
#create(config_xml) ⇒ Object
Create a new job from config.xml.
-
#credentials(params = {}) ⇒ Object
cloudbees-folder plugin provides special type of job - folder.
-
#disable ⇒ Object
Disable a job, restrict all builds of the job from now on.
-
#enable ⇒ Object
Enable job, allow building the job.
-
#job(name, **params) ⇒ Object
cloudbees-folder plugin provides special type of job - folder.
- #polling ⇒ Object
Methods included from RUD
Methods inherited from ResourceProxy
#initialize, #method_missing, #raw, #respond_to_missing?, #subject
Constructor Details
This class inherits a constructor from Jenkins2::ResourceProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jenkins2::ResourceProxy
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
22 23 24 |
# File 'lib/jenkins2/api/job.rb', line 22 def id @id end |
Instance Method Details
#build(build_parameters = {}) ⇒ Object
Schedule a job build. Allows to pass build parameters, if required.
Returns:
True on success.
64 65 66 67 68 69 70 |
# File 'lib/jenkins2/api/job.rb', line 64 def build(build_parameters={}) if build_parameters.empty? connection.post(build_path('build')) else connection.post(build_path('buildWithParameters'), nil, build_parameters) end.code == '201' end |
#copy(from) ⇒ Object
Create a new job by copying another one.
Parameters:
from
-
Job name to copy new job from.
Returns:
True on success.
42 43 44 45 |
# File 'lib/jenkins2/api/job.rb', line 42 def copy(from) path = ::File.join(::File.dirname(@path), 'createItem') connection.post(path, nil, name: id, from: from, mode: 'copy').code == '302' end |
#create(config_xml) ⇒ Object
Create a new job from config.xml.
Parameters:
config_xml
-
config.xml of new job as string.
Returns:
True on success
30 31 32 33 34 35 |
# File 'lib/jenkins2/api/job.rb', line 30 def create(config_xml) path = ::File.join(::File.dirname(@path), 'createItem') connection.post(path, config_xml, name: id) do |req| req['Content-Type'] = 'text/xml' end.code == '200' end |
#credentials(params = {}) ⇒ Object
cloudbees-folder plugin provides special type of job - folder. You can now create credentials inside particular folder.
Parameters:
params
-
Key-value parameters. They will be added as URL parameters to request.
Returns:
A new Jenkins2::API::Credentials::Proxy object
95 96 97 |
# File 'lib/jenkins2/api/job.rb', line 95 def credentials(params={}) ::Jenkins2::API::Credentials::Proxy.new connection, build_path('credentials'), params end |
#disable ⇒ Object
Disable a job, restrict all builds of the job from now on.
Returns:
True on success.
50 51 52 |
# File 'lib/jenkins2/api/job.rb', line 50 def disable connection.post(build_path('disable')).code == '302' end |
#enable ⇒ Object
Enable job, allow building the job. Cancels previously issued “disable”.
Returns:
True on success.
57 58 59 |
# File 'lib/jenkins2/api/job.rb', line 57 def enable connection.post(build_path('enable')).code == '302' end |
#job(name, **params) ⇒ Object
cloudbees-folder plugin provides special type of job - folder. So now we can have nested jobs. This methods allows to go 1 job deeper.
Parameters:
name
-
Job name
params
-
Key-value parameters. They will be added as URL parameters to request.
Returns:
A new Jenkins2::API::Job::Proxy object
83 84 85 86 87 |
# File 'lib/jenkins2/api/job.rb', line 83 def job(name, **params) proxy = Proxy.new connection, build_path('job'), params proxy.id = name proxy end |
#polling ⇒ Object
72 73 74 |
# File 'lib/jenkins2/api/job.rb', line 72 def polling connection.post(build_path('polling')).code == '302' end |