foreman_pipeline 0.0.11 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -1
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details-info.controller.js +23 -2
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details.controller.js +1 -23
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-info.html +31 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-users.html +17 -14
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details.html +3 -10
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.module.js +4 -1
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/new-jenkins-instance.controller.js +4 -7
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/views/new-jenkins-instance-form.html +18 -3
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/new/new-jenkins-user.controller.js +5 -5
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-content-views.controller.js +3 -3
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-hostgroups.controller.js +3 -5
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-jenkins-projects.controller.js +2 -2
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/job-projects-discovery.controller.js +10 -1
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-projects-discovery.html +20 -12
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-content-views.html +12 -8
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-environments.html +10 -6
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-hostgroups.html +6 -2
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins-projects.html +7 -6
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins.html +15 -11
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-resources.html +16 -12
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-to-environments.html +11 -7
- data/app/assets/javascripts/foreman_pipeline/jobs/jobs.module.js +4 -1
- data/app/assets/stylesheets/foreman_pipeline/foreman_pipeline.css +4 -0
- data/app/controllers/foreman_pipeline/api/jenkins_instances_controller.rb +10 -3
- data/app/controllers/foreman_pipeline/api/jenkins_projects_controller.rb +1 -1
- data/app/controllers/foreman_pipeline/api/jenkins_users_controller.rb +1 -1
- data/app/controllers/foreman_pipeline/api/jobs_controller.rb +44 -48
- data/app/lib/actions/foreman_pipeline/jenkins/build.rb +9 -3
- data/app/lib/actions/foreman_pipeline/jenkins/build_project.rb +2 -0
- data/app/lib/actions/foreman_pipeline/jenkins/bulk_build.rb +4 -0
- data/app/lib/actions/foreman_pipeline/jenkins/list.rb +4 -0
- data/app/lib/actions/foreman_pipeline/jenkins_instance/create_jenkins_instance_keys.rb +1 -1
- data/app/lib/actions/foreman_pipeline/job/create_host.rb +2 -2
- data/app/lib/actions/foreman_pipeline/job/cv_promote_job_hook.rb +1 -3
- data/app/lib/actions/foreman_pipeline/job/cv_publish_job_hook.rb +1 -3
- data/app/lib/actions/foreman_pipeline/job/job_hook.rb +4 -3
- data/app/lib/actions/foreman_pipeline/job/repo_sync_job_hook.rb +4 -17
- data/app/lib/actions/foreman_pipeline/job/run_job_manually.rb +2 -11
- data/app/lib/actions/foreman_pipeline/job/wait_until_provisioned.rb +4 -1
- data/app/lib/actions/foreman_pipeline/mixins/uri_extension.rb +1 -1
- data/app/models/foreman_pipeline/jenkins_instance.rb +8 -6
- data/app/models/foreman_pipeline/jenkins_project.rb +2 -4
- data/app/models/foreman_pipeline/jenkins_project_param.rb +0 -1
- data/app/models/foreman_pipeline/jenkins_user.rb +0 -2
- data/app/models/foreman_pipeline/job.rb +24 -8
- data/app/models/foreman_pipeline/job_to_environment.rb +0 -2
- data/app/services/foreman_pipeline/job_filter.rb +34 -0
- data/app/views/foreman/unattended/snippets/_jenkins_instance_pubkey.erb +3 -3
- data/app/views/foreman_pipeline/api/jenkins_instances/show.json.rabl +1 -1
- data/config/routes.rb +2 -7
- data/db/migrate/20150209160604_add_jenkins_home_to_jenkins_instance_table.rb +1 -1
- data/db/migrate/20150213095447_add_cert_path_to_jenkins_instances.rb +1 -1
- data/db/migrate/20150223142315_change_jenkins_instance_cert_path_column.rb +1 -1
- data/db/migrate/20150224090100_create_jenkins_projects_table.rb +4 -4
- data/db/migrate/20160404102405_update_projects_table.rb +9 -0
- data/db/migrate/20160404133012_drop_job_jenkins_project.rb +30 -0
- data/db/migrate/20160629085119_add_timeout_to_jenkins_instance.rb +9 -0
- data/db/seeds.d/location.rb +9 -0
- data/db/seeds.d/snippets.rb +11 -0
- data/lib/foreman_pipeline/engine.rb +1 -2
- data/lib/foreman_pipeline/plugin.rb +1 -1
- data/lib/foreman_pipeline/roles.rb +3 -3
- data/lib/foreman_pipeline/skip_tests.rb +22 -6
- data/lib/foreman_pipeline/tasks/{foreman_pipeline_test.rake → test.rake} +3 -2
- data/lib/foreman_pipeline/version.rb +1 -1
- data/test/fixtures/jenkins_instances.yml +8 -0
- data/test/fixtures/jenkins_projects.yml +9 -0
- data/test/fixtures/jenkins_users.yml +4 -0
- data/test/fixtures/jobs.yml +47 -0
- data/test/fixtures/pipeline_compute_attributes.yml +20 -0
- data/test/fixtures/pipeline_compute_profiles.yml +5 -0
- data/test/fixtures/pipeline_hostgroups.yml +25 -0
- data/test/fixtures_support.rb +17 -0
- data/test/{foreman_pipeline_plugin_test_helper.rb → foreman_pipeline_test_helper.rb} +17 -8
- data/test/functional/foreman_pipeline/api/jenkins_users_controller_test.rb +47 -0
- data/test/functional/foreman_pipeline/api/jobs_controller_test.rb +186 -0
- data/test/{unit → models}/jenkins_instance_test.rb +1 -1
- data/test/{unit → models}/job_test.rb +111 -55
- data/test/services/job_filter_test.rb +59 -0
- metadata +37 -16
- data/app/models/foreman_pipeline/job_jenkins_project.rb +0 -27
- data/lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake +0 -28
- data/test/factories/hostgroup_factory.rb +0 -5
- data/test/unit/sanity_test.rb +0 -12
@@ -41,7 +41,7 @@ module ForemanPipeline
|
|
41
41
|
param_group :jenkins_user_id
|
42
42
|
param_group :jenkins_user
|
43
43
|
def update
|
44
|
-
if jenkins_user_params[:token].empty?
|
44
|
+
if jenkins_user_params[:token].empty?
|
45
45
|
@jenkins_user.update_attributes!(jenkins_user_params.except(:token).except(:name))
|
46
46
|
else
|
47
47
|
@jenkins_user.update_attributes!(jenkins_user_params.except(:name))
|
@@ -8,10 +8,11 @@ module ForemanPipeline
|
|
8
8
|
before_filter :find_organization, :only => [:create, :index, :add_projects, :available_paths]
|
9
9
|
|
10
10
|
before_filter :find_job, :only => [:update, :show, :destroy, :set_content_view,
|
11
|
-
:set_hostgroup, :set_resource,
|
12
|
-
:set_jenkins, :
|
13
|
-
:add_projects, :remove_projects, :set_to_environments
|
14
|
-
|
11
|
+
:set_hostgroup, :set_resource,
|
12
|
+
:set_jenkins, :run_job, :set_environment,
|
13
|
+
:add_projects, :remove_projects, :set_to_environments]
|
14
|
+
before_filter(:only => [:available_resources, :available_paths]) { find_job [] }
|
15
|
+
before_filter :job_filter, :only => [:run_job]
|
15
16
|
|
16
17
|
def_param_group :job do
|
17
18
|
param :name, String, :desc => N_("Name of the job"), :required => true
|
@@ -30,7 +31,7 @@ module ForemanPipeline
|
|
30
31
|
param :organization_id, :number, :desc => N_("organization identifier"), :required => true
|
31
32
|
param :name, String, :desc => N_("Name of the job")
|
32
33
|
def index
|
33
|
-
respond_for_index(:collection => scoped_search(index_relation.uniq, params[:sort_by], params[:sort_order]))
|
34
|
+
respond_for_index(:collection => scoped_search(index_relation.uniq, params[:sort_by], params[:sort_order], :includes => job_includes))
|
34
35
|
end
|
35
36
|
|
36
37
|
def index_relation
|
@@ -81,7 +82,6 @@ module ForemanPipeline
|
|
81
82
|
param :content_view_id, :number, :desc => N_("Content view id which will be set"), :required => true
|
82
83
|
def set_content_view
|
83
84
|
cv = Katello::ContentView.find(params[:content_view_id])
|
84
|
-
fail Katello::HttpErrors::Conflict, "Only non-composite views are accepted" if cv.composite?
|
85
85
|
@job.content_view = cv
|
86
86
|
@job.save!
|
87
87
|
respond_for_show
|
@@ -121,31 +121,18 @@ module ForemanPipeline
|
|
121
121
|
param_group :job_id
|
122
122
|
param :resource_id, :number, :desc => N_("Compute resource id which will be set"), :required => true
|
123
123
|
def set_resource
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
respond_for_show
|
128
|
-
else
|
129
|
-
fail Katello::HttpErrors::Conflict, "Only a Compute Resource configured for Job's Hostgroup may be set."
|
130
|
-
end
|
124
|
+
@job.compute_resource = ComputeResource.find(params[:resource_id])
|
125
|
+
@job.save!
|
126
|
+
respond_for_show
|
131
127
|
end
|
132
128
|
|
133
129
|
api :PUT, "/organizations/:organization_id/jobs/:id/set_to_environments", N_("Set 'to environments' for the job")
|
134
130
|
param_group :job_id
|
135
131
|
param :path_ids, Array, :desc => N_("Identifiers of environments which are successors of job's environment")
|
136
132
|
def set_to_environments
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
@job.environment.successors.map(&:id).include? new_id
|
141
|
-
end.all?
|
142
|
-
if is_ok
|
143
|
-
@job.to_environment_ids = params[:to_environment_ids]
|
144
|
-
@job.save!
|
145
|
-
respond_for_show
|
146
|
-
else
|
147
|
-
fail Katello::HttpErrors::Conflict, "Only environments that are direct successors of Job's Environment may be set as 'to environments'."
|
148
|
-
end
|
133
|
+
@job.to_environment_ids = params[:to_environment_ids]
|
134
|
+
@job.save!
|
135
|
+
respond_for_show
|
149
136
|
end
|
150
137
|
|
151
138
|
api :GET, "/organizations/:organization_id/jobs/:id/available_paths", N_("List environment paths available for a job")
|
@@ -187,28 +174,29 @@ module ForemanPipeline
|
|
187
174
|
param_group :job_id
|
188
175
|
def run_job
|
189
176
|
if @job.manual_trigger
|
190
|
-
|
191
|
-
|
177
|
+
if @filter.allow_run_for? @job
|
178
|
+
task = async_task(::Actions::ForemanPipeline::Job::RunJobManually, @job)
|
179
|
+
render :nothing => true
|
180
|
+
else
|
181
|
+
fail ::Katello::HttpErrors::Forbidden, "Job cannot be allowed to run, check your configuration"
|
182
|
+
end
|
192
183
|
else
|
193
184
|
fail ::Katello::HttpErrors::Forbidden, "Running manually not allowed for Job: #{@job.name}. Try setting it's :manual_trigger property."
|
194
185
|
end
|
195
186
|
end
|
196
187
|
|
197
|
-
api :
|
188
|
+
api :PUT, "/organizations/:organization_id/jobs/:id/add_projects", N_("Add jenkins projects to the job")
|
198
189
|
param_group :job_id
|
199
190
|
param :projects, Array, :desc => N_("Names of the jenkins projects to be added to the job")
|
200
191
|
def add_projects
|
201
|
-
rollback = {:occured => false}
|
192
|
+
rollback = { :occured => false }
|
202
193
|
Job.transaction do
|
203
|
-
|
204
|
-
|
194
|
+
names = params[:projects].delete_if { |name| @job.jenkins_projects.map(&:name).include? name }
|
195
|
+
projects = names.map do |name|
|
196
|
+
JenkinsProject.create(:name => name, :organization_id => @organization.id, :job_id => @job.id)
|
205
197
|
end
|
206
|
-
projects_to_add = projects.delete_if { |p| @job.jenkins_projects.include? p }
|
207
|
-
@job.jenkins_projects = @job.jenkins_projects + projects_to_add
|
208
|
-
@job.save!
|
209
198
|
|
210
|
-
|
211
|
-
project.reload
|
199
|
+
projects.each do |project|
|
212
200
|
task = sync_task(::Actions::ForemanPipeline::Jenkins::GetBuildParams, :job_id => @job.id, :name => project.name)
|
213
201
|
|
214
202
|
unless task.output[:build_params]
|
@@ -217,13 +205,12 @@ module ForemanPipeline
|
|
217
205
|
rollback[:project_name] = project.name
|
218
206
|
end
|
219
207
|
task.output[:build_params].each do |param|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
new_param.save!
|
208
|
+
JenkinsProjectParam.create(:name => param[:name],
|
209
|
+
:type => param[:type],
|
210
|
+
:description => param[:description],
|
211
|
+
:value => param[:default],
|
212
|
+
:organization => @organization,
|
213
|
+
:jenkins_project => project)
|
227
214
|
end
|
228
215
|
end
|
229
216
|
end
|
@@ -234,20 +221,25 @@ module ForemanPipeline
|
|
234
221
|
end
|
235
222
|
end
|
236
223
|
|
237
|
-
api :
|
224
|
+
api :PUT, "/organizations/:organization_id/jobs/:id/remove_projects", N_("Remove jenkins projects from the job")
|
238
225
|
param_group :job_id
|
239
226
|
param :projects, Array, :desc => N_("Identifiers of the projects to be removed from the job")
|
240
227
|
def remove_projects
|
241
228
|
ids = params[:project_ids]
|
242
|
-
|
243
|
-
|
229
|
+
projects = JenkinsProject.where(:id => ids)
|
230
|
+
projects.map(&:destroy)
|
244
231
|
respond_for_show
|
245
232
|
end
|
246
233
|
|
247
234
|
protected
|
248
235
|
|
249
|
-
def
|
250
|
-
|
236
|
+
def job_includes
|
237
|
+
[:content_view, :hostgroup, :compute_resource, :jenkins_instance, :to_environments, :environment => [:successors],
|
238
|
+
:jenkins_projects => [:jenkins_project_params]]
|
239
|
+
end
|
240
|
+
|
241
|
+
def find_job(find_includes = job_includes)
|
242
|
+
@job = Job.includes(find_includes).where(:id => params[:id]).first
|
251
243
|
fail ::Katello::HttpErrors::NotFound, "Could not find job with id #{params[:id]}" if @job.nil?
|
252
244
|
@job
|
253
245
|
end
|
@@ -256,6 +248,10 @@ module ForemanPipeline
|
|
256
248
|
params.require(:job).permit(:name, :manual_trigger, :sync_trigger, :levelup_trigger, :projects, :promote)
|
257
249
|
end
|
258
250
|
|
251
|
+
def job_filter
|
252
|
+
@filter ||= ForemanPipeline::JobFilter.new
|
253
|
+
end
|
254
|
+
|
259
255
|
def format_paths(paths)
|
260
256
|
formated_paths = paths.inject([]) do |result, path|
|
261
257
|
result << { :environments => path }
|
@@ -5,10 +5,12 @@ module Actions
|
|
5
5
|
class Build < AbstractJenkinsAction
|
6
6
|
|
7
7
|
def run
|
8
|
-
|
9
|
-
output[:build_num] = job.jenkins_instance.client.job.build(jenkins_project.name, params, 'build_start_timeout' => 300)
|
8
|
+
timeout = job.jenkins_instance.timeout_sec
|
10
9
|
output[:project_name] = jenkins_project.name
|
11
10
|
output[:build_params] = params
|
11
|
+
output[:build_num] = job.jenkins_instance.client.job.build(jenkins_project.name, params, 'build_start_timeout' => timeout)
|
12
|
+
rescue => e
|
13
|
+
fail "Jenkins build for #{jenkins_project.name} failed to start in a timely manner."
|
12
14
|
end
|
13
15
|
|
14
16
|
def params
|
@@ -17,6 +19,10 @@ module Actions
|
|
17
19
|
template_binding project_params
|
18
20
|
end
|
19
21
|
|
22
|
+
def rescue_strategy_for_self
|
23
|
+
Dynflow::Action::Rescue::Skip
|
24
|
+
end
|
25
|
+
|
20
26
|
def template_binding(project_params)
|
21
27
|
host = input[:data][:host]
|
22
28
|
activation_key = input[:data][:activation_key]
|
@@ -32,4 +38,4 @@ module Actions
|
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
35
|
-
end
|
41
|
+
end
|
@@ -17,6 +17,10 @@ module Actions
|
|
17
17
|
trigger(BuildProject, input[:opts].merge({:project_id => project.id, :project_name => project.name}))
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
def check_for_errors!
|
22
|
+
# Do nothing. Just wait for all builds to finish and gather results
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -6,6 +6,10 @@ module Actions
|
|
6
6
|
output[:projects] = job.jenkins_instance.client.job.list input[:filter]
|
7
7
|
end
|
8
8
|
|
9
|
+
def rescue_strategy_for_self
|
10
|
+
Dynflow::Action::Rescue::Skip
|
11
|
+
end
|
12
|
+
|
9
13
|
def humanized_name
|
10
14
|
"List projects in Jenkins Instance: %s" % job.jenkins_instance.name
|
11
15
|
end
|
@@ -15,7 +15,7 @@ module Actions
|
|
15
15
|
buffer = StringIO.new
|
16
16
|
ip = Socket::getaddrinfo(host, 'www', nil, Socket::SOCK_STREAM)[0][3]
|
17
17
|
|
18
|
-
Net::SSH.start(ip, 'root', :keys => [input.fetch(:cert_path)]) do |ssh|
|
18
|
+
Net::SSH.start(ip, 'root', :keys => [input.fetch(:cert_path)], :non_interactive => true) do |ssh|
|
19
19
|
status = ssh_exec!(ssh, "ls #{key_location}")[2]
|
20
20
|
ssh.exec!("mkdir #{key_location}") if status > 0
|
21
21
|
ssh.exec! "sed -i s:Defaults\\.*requiretty:#Defaults\\ requiretty:g /etc/sudoers"
|
@@ -36,7 +36,7 @@ module Actions
|
|
36
36
|
|
37
37
|
organization_param
|
38
38
|
keys_param
|
39
|
-
|
39
|
+
host.apply_compute_profile(InterfaceMerge.new)
|
40
40
|
host.save!
|
41
41
|
jenkins_pubkey_param_for host
|
42
42
|
host.power.start
|
@@ -77,7 +77,7 @@ module Actions
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def jenkins_pubkey_param_for(host)
|
80
|
-
::HostParameter.create(:name => '
|
80
|
+
::HostParameter.create(:name => 'pipeline_jenkins_pubkey', :value => jenkins_pubkey, :reference_id => host.id)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -8,9 +8,7 @@ module Actions
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def plan(version, environment, is_force = false)
|
11
|
-
|
12
|
-
jobs_to_run = valid_jobs.select { |job| version.eql? job.target_cv_version }
|
13
|
-
allowed_jobs = jobs_to_run.select { |job| job.levelup_trigger && job.not_yet_promoted? }
|
11
|
+
allowed_jobs = filter.allowed_jobs_for_cvv version
|
14
12
|
|
15
13
|
plan_self(:trigger => trigger.output,
|
16
14
|
:job_ids => allowed_jobs.map(&:id),
|
@@ -8,9 +8,7 @@ module Actions
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def plan(content_view, descripton)
|
11
|
-
|
12
|
-
jobs_to_run = valid_jobs.select { |job| job.environment.library? }
|
13
|
-
allowed_jobs = jobs_to_run.select { |job| job.levelup_trigger && job.not_yet_promoted? }
|
11
|
+
allowed_jobs = filter.allowed_jobs_for_cv content_view
|
14
12
|
|
15
13
|
plan_self(:trigger => trigger.output,
|
16
14
|
:job_ids => allowed_jobs.map(&:id),
|
@@ -5,15 +5,16 @@ module Actions
|
|
5
5
|
middleware.use ::Actions::Middleware::KeepCurrentUser
|
6
6
|
|
7
7
|
def run
|
8
|
-
fail "Multiple jobs defined for the same content view and environment: #{input[:job_names]}.
|
9
|
-
This may result in an unexpected behaviour.
|
10
|
-
Resolve the conflict to avoid skipping this action." if input[:job_names].length > 1
|
11
8
|
jobs = input[:job_ids].map { |id| ::ForemanPipeline::Job.find id }
|
12
9
|
jobs.map do |job|
|
13
10
|
ForemanTasks.trigger(DeployNewHost, job)
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
14
|
+
def filter
|
15
|
+
@filter ||= ::ForemanPipeline::JobFilter.new
|
16
|
+
end
|
17
|
+
|
17
18
|
def rescue_strategy_for_self
|
18
19
|
Dynflow::Action::Rescue::Skip
|
19
20
|
end
|
@@ -8,24 +8,11 @@ module Actions
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def plan(repo)
|
11
|
-
|
11
|
+
allowed_jobs = filter.allowed_jobs_for_repo repo
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
if grouped_jobs.max_by(&:length).length > 1
|
18
|
-
grouped_jobs = grouped_jobs.max_by(&:length)
|
19
|
-
|
20
|
-
plan_self(:trigger => trigger.output,
|
21
|
-
:job_ids => grouped_jobs.map(&:id),
|
22
|
-
:job_names => grouped_jobs.map(&:name))
|
23
|
-
else
|
24
|
-
grouped_jobs.flatten!
|
25
|
-
plan_self(:trigger => trigger.output,
|
26
|
-
:job_names => [],
|
27
|
-
:job_ids => grouped_jobs.map(&:id))
|
28
|
-
end
|
13
|
+
plan_self(:trigger => trigger.output,
|
14
|
+
:job_ids => allowed_jobs.map(&:id),
|
15
|
+
:job_names => allowed_jobs.map(&:name))
|
29
16
|
end
|
30
17
|
end
|
31
18
|
end
|
@@ -4,21 +4,12 @@ module Actions
|
|
4
4
|
class RunJobManually < Actions::EntryAction
|
5
5
|
|
6
6
|
def plan(job)
|
7
|
-
|
8
|
-
|
9
|
-
plan_self(:info => "Manually triggered job started.", :name => job.name)
|
10
|
-
else
|
11
|
-
plan_self(:info => "Manually triggered job execution skipped, check job configuration.", :name => job.name, :fail => true)
|
12
|
-
end
|
7
|
+
plan_action(DeployNewHost, job)
|
8
|
+
plan_self(:info => "Manually triggered job started.", :name => job.name)
|
13
9
|
end
|
14
10
|
|
15
11
|
def run
|
16
12
|
output = input
|
17
|
-
fail input[:info] if input[:fail]
|
18
|
-
end
|
19
|
-
|
20
|
-
def rescue_strategy_for_self
|
21
|
-
Dynflow::Action::Rescue::Skip
|
22
13
|
end
|
23
14
|
|
24
15
|
def humanized_name
|
@@ -34,8 +34,11 @@ module Actions
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def build_status(host = nil)
|
37
|
+
info = "Cannot find host by id" if host.nil?
|
38
|
+
info = "Host not yet created, no reports received" if !host.nil? && host.reports.count < 1
|
39
|
+
info = "Host has invalid configuration" if !host.nil? && (host.reports.count > 1) && host.reports.last.error?
|
37
40
|
status = (!host.nil? && (host.reports.count > 1) && !host.reports.last.error?)
|
38
|
-
{ :build => status }
|
41
|
+
{ :build => status, :info => info }
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
@@ -8,8 +8,6 @@ module ForemanPipeline
|
|
8
8
|
include Katello::Glue
|
9
9
|
include ForemanPipeline::Authorization::JenkinsInstance
|
10
10
|
|
11
|
-
attr_accessible :name, :url, :organization_id, :pubkey, :jenkins_home, :cert_path, :jenkins_user_id
|
12
|
-
|
13
11
|
belongs_to :organization
|
14
12
|
has_many :jobs, :class_name => "ForemanPipeline::Job", :dependent => :nullify
|
15
13
|
belongs_to :jenkins_user, :class_name => "ForemanPipeline::JenkinsUser"
|
@@ -17,8 +15,9 @@ module ForemanPipeline
|
|
17
15
|
FILEPATH_REGEX = /\A(\/|~)[a-z0-9\-_.\/]*[^\/]\z/i
|
18
16
|
|
19
17
|
validates :name, :presence => true
|
20
|
-
validates :
|
21
|
-
validates :
|
18
|
+
validates :timeout, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0 }
|
19
|
+
validates :cert_path, :format => { :with => FILEPATH_REGEX }
|
20
|
+
validates :url, :uniqueness => true, :format => { :with => /\A(http|https):\/\/\S+:\d{1,4}\z/ }
|
22
21
|
validates :organization, :presence => true
|
23
22
|
validates :jenkins_home, :format => { :with => FILEPATH_REGEX }
|
24
23
|
|
@@ -37,6 +36,10 @@ module ForemanPipeline
|
|
37
36
|
@client
|
38
37
|
end
|
39
38
|
|
39
|
+
def timeout_sec
|
40
|
+
timeout * 60
|
41
|
+
end
|
42
|
+
|
40
43
|
private
|
41
44
|
|
42
45
|
def authenticated_client(username, password, hash_args)
|
@@ -49,6 +52,5 @@ module ForemanPipeline
|
|
49
52
|
return JenkinsApi::Client.new(hash_args) if username.nil?
|
50
53
|
authenticated_client username, password, hash_args
|
51
54
|
end
|
52
|
-
|
53
55
|
end
|
54
|
-
end
|
56
|
+
end
|
@@ -7,11 +7,9 @@ module ForemanPipeline
|
|
7
7
|
|
8
8
|
belongs_to :organization
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
has_many :job_jenkins_projects, :dependent => :destroy
|
13
|
-
has_many :jobs, :through => :job_jenkins_projects, :class_name => 'ForemanPipeline::Job'
|
10
|
+
validates :name, :presence => true, :uniqueness => true
|
14
11
|
|
12
|
+
belongs_to :job, :class_name => 'ForemanPipeline::Job', :inverse_of => :jenkins_projects
|
15
13
|
has_many :jenkins_project_params, :class_name => 'ForemanPipeline::JenkinsProjectParam', :dependent => :destroy
|
16
14
|
|
17
15
|
accepts_nested_attributes_for :jenkins_project_params
|