foreman_pipeline 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE +674 -0
  3. data/README.md +36 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/javascripts/foreman_pipeline/foreman_pipeline-bootstrap.js +8 -0
  6. data/app/assets/javascripts/foreman_pipeline/foreman_pipeline.js +20 -0
  7. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details-info.controller.js +46 -0
  8. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details-users.controller.js +72 -0
  9. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details.controller.js +40 -0
  10. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-info.html +36 -0
  11. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-users.html +107 -0
  12. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details.html +53 -0
  13. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.controller.js +34 -0
  14. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.factory.js +14 -0
  15. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.module.js +93 -0
  16. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/new-jenkins-instance.controller.js +40 -0
  17. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/views/new-jenkins-instance-form.html +50 -0
  18. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/views/new-jenkins-instance.html +16 -0
  19. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/views/jenkins-instances-table-collapsed.html +20 -0
  20. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/views/jenkins-instances-table-full.html +30 -0
  21. data/app/assets/javascripts/foreman_pipeline/jenkins-instances/views/jenkins-instances.html +17 -0
  22. data/app/assets/javascripts/foreman_pipeline/jenkins-project-params/jenkins-project-params.factory.js +11 -0
  23. data/app/assets/javascripts/foreman_pipeline/jenkins-project-params/jenkins-project-params.module.js +6 -0
  24. data/app/assets/javascripts/foreman_pipeline/jenkins-projects/jenkins-projects.factory.js +9 -0
  25. data/app/assets/javascripts/foreman_pipeline/jenkins-projects/jenkins-projects.module.js +10 -0
  26. data/app/assets/javascripts/foreman_pipeline/jenkins-requests/jenkins-requests.factory.js +11 -0
  27. data/app/assets/javascripts/foreman_pipeline/jenkins-requests/jenkins-requests.module.js +10 -0
  28. data/app/assets/javascripts/foreman_pipeline/jenkins-users/details/jenkins-user-info.controller.js +39 -0
  29. data/app/assets/javascripts/foreman_pipeline/jenkins-users/details/views/jenkins-user-info.html +37 -0
  30. data/app/assets/javascripts/foreman_pipeline/jenkins-users/jenkins-users.factory.js +10 -0
  31. data/app/assets/javascripts/foreman_pipeline/jenkins-users/jenkins-users.module.js +6 -0
  32. data/app/assets/javascripts/foreman_pipeline/jenkins-users/new/new-jenkins-user.controller.js +45 -0
  33. data/app/assets/javascripts/foreman_pipeline/jenkins-users/new/views/new-jenkins-user.html +32 -0
  34. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-add-paths.controller.js +63 -0
  35. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-content-views.controller.js +55 -0
  36. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-environments.controller.js +56 -0
  37. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-hostgroups.controller.js +59 -0
  38. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-info.controller.js +69 -0
  39. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-jenkins-projects.controller.js +49 -0
  40. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-jenkins.controller.js +56 -0
  41. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-resources.controller.js +60 -0
  42. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-to-environments.controller.js +157 -0
  43. data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details.controller.js +34 -0
  44. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/job-projects-discovery.controller.js +96 -0
  45. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/job-projects-parameters.controller.js +54 -0
  46. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-jenkins-projects.html +1 -0
  47. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-projects-discovery.html +91 -0
  48. data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-projects-parameters.html +77 -0
  49. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-content-views.html +83 -0
  50. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-environments.html +50 -0
  51. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-hostgroups.html +81 -0
  52. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-info.html +117 -0
  53. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins-projects.html +75 -0
  54. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins.html +88 -0
  55. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-paths-list.html +72 -0
  56. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-resources.html +86 -0
  57. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-to-environments.html +51 -0
  58. data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details.html +80 -0
  59. data/app/assets/javascripts/foreman_pipeline/jobs/jobs.controller.js +40 -0
  60. data/app/assets/javascripts/foreman_pipeline/jobs/jobs.factory.js +54 -0
  61. data/app/assets/javascripts/foreman_pipeline/jobs/jobs.module.js +142 -0
  62. data/app/assets/javascripts/foreman_pipeline/jobs/new/new-job.controller.js +31 -0
  63. data/app/assets/javascripts/foreman_pipeline/jobs/new/views/new-job-form.html +47 -0
  64. data/app/assets/javascripts/foreman_pipeline/jobs/new/views/new-job.html +17 -0
  65. data/app/assets/javascripts/foreman_pipeline/jobs/views/jobs-table-collapsed.html +20 -0
  66. data/app/assets/javascripts/foreman_pipeline/jobs/views/jobs-table-full.html +66 -0
  67. data/app/assets/javascripts/foreman_pipeline/jobs/views/jobs.html +19 -0
  68. data/app/assets/javascripts/foreman_pipeline/jobs/views/pln-path-selector.html +10 -0
  69. data/app/assets/stylesheets/foreman_pipeline/foreman_pipeline.css +13 -0
  70. data/app/controllers/foreman_pipeline/api/jenkins_instances_controller.rb +124 -0
  71. data/app/controllers/foreman_pipeline/api/jenkins_project_params_controller.rb +34 -0
  72. data/app/controllers/foreman_pipeline/api/jenkins_projects_controller.rb +29 -0
  73. data/app/controllers/foreman_pipeline/api/jenkins_requests_controller.rb +28 -0
  74. data/app/controllers/foreman_pipeline/api/jenkins_users_controller.rb +89 -0
  75. data/app/controllers/foreman_pipeline/api/jobs_controller.rb +271 -0
  76. data/app/controllers/foreman_pipeline/application_controller.rb +4 -0
  77. data/app/helpers/foreman_pipeline/application_helper.rb +4 -0
  78. data/app/lib/actions/foreman_pipeline/jenkins/abstract_jenkins_action.rb +20 -0
  79. data/app/lib/actions/foreman_pipeline/jenkins/build.rb +35 -0
  80. data/app/lib/actions/foreman_pipeline/jenkins/build_project.rb +31 -0
  81. data/app/lib/actions/foreman_pipeline/jenkins/bulk_build.rb +23 -0
  82. data/app/lib/actions/foreman_pipeline/jenkins/get_build_details.rb +11 -0
  83. data/app/lib/actions/foreman_pipeline/jenkins/get_build_params.rb +11 -0
  84. data/app/lib/actions/foreman_pipeline/jenkins/get_version.rb +17 -0
  85. data/app/lib/actions/foreman_pipeline/jenkins/list.rb +15 -0
  86. data/app/lib/actions/foreman_pipeline/jenkins/wait_and_poll.rb +33 -0
  87. data/app/lib/actions/foreman_pipeline/jenkins/wait_for_build.rb +42 -0
  88. data/app/lib/actions/foreman_pipeline/jenkins/wait_host_ready.rb +36 -0
  89. data/app/lib/actions/foreman_pipeline/jenkins_instance/abstract_jenkins_instance_action.rb +17 -0
  90. data/app/lib/actions/foreman_pipeline/jenkins_instance/create_jenkins_instance_keys.rb +45 -0
  91. data/app/lib/actions/foreman_pipeline/job/create_activation_key.rb +20 -0
  92. data/app/lib/actions/foreman_pipeline/job/create_host.rb +88 -0
  93. data/app/lib/actions/foreman_pipeline/job/cv_promote_job_hook.rb +22 -0
  94. data/app/lib/actions/foreman_pipeline/job/cv_publish_job_hook.rb +22 -0
  95. data/app/lib/actions/foreman_pipeline/job/deploy_new_host.rb +25 -0
  96. data/app/lib/actions/foreman_pipeline/job/find_packages_to_install.rb +16 -0
  97. data/app/lib/actions/foreman_pipeline/job/job_hook.rb +24 -0
  98. data/app/lib/actions/foreman_pipeline/job/multiple_promotions.rb +18 -0
  99. data/app/lib/actions/foreman_pipeline/job/promote.rb +38 -0
  100. data/app/lib/actions/foreman_pipeline/job/redeploy.rb +45 -0
  101. data/app/lib/actions/foreman_pipeline/job/repo_sync_job_hook.rb +33 -0
  102. data/app/lib/actions/foreman_pipeline/job/run_job_manually.rb +25 -0
  103. data/app/lib/actions/foreman_pipeline/job/suspend_until_provisioned.rb +13 -0
  104. data/app/lib/actions/foreman_pipeline/mixins/ssh_extension.rb +41 -0
  105. data/app/lib/actions/foreman_pipeline/mixins/uri_extension.rb +14 -0
  106. data/app/lib/foreman_pipeline/api/rendering.rb +18 -0
  107. data/app/models/foreman_pipeline/authorization/base_model.rb +31 -0
  108. data/app/models/foreman_pipeline/authorization/jenkins_instance.rb +8 -0
  109. data/app/models/foreman_pipeline/authorization/jenkins_project.rb +8 -0
  110. data/app/models/foreman_pipeline/authorization/jenkins_project_param.rb +8 -0
  111. data/app/models/foreman_pipeline/authorization/jenkins_user.rb +7 -0
  112. data/app/models/foreman_pipeline/authorization/job.rb +7 -0
  113. data/app/models/foreman_pipeline/concerns/compute_resource_extension.rb +11 -0
  114. data/app/models/foreman_pipeline/concerns/content_view_extension.rb +12 -0
  115. data/app/models/foreman_pipeline/concerns/content_view_repository_extension.rb +12 -0
  116. data/app/models/foreman_pipeline/concerns/hostgroup_extension.rb +12 -0
  117. data/app/models/foreman_pipeline/concerns/kt_environment_extension.rb +18 -0
  118. data/app/models/foreman_pipeline/concerns/repository_extension.rb +12 -0
  119. data/app/models/foreman_pipeline/glue/elastic_search/base_model.rb +21 -0
  120. data/app/models/foreman_pipeline/glue/elastic_search/jenkins_instance.rb +11 -0
  121. data/app/models/foreman_pipeline/glue/elastic_search/jenkins_project.rb +11 -0
  122. data/app/models/foreman_pipeline/glue/elastic_search/jenkins_user.rb +11 -0
  123. data/app/models/foreman_pipeline/glue/elastic_search/job.rb +11 -0
  124. data/app/models/foreman_pipeline/jenkins_instance.rb +51 -0
  125. data/app/models/foreman_pipeline/jenkins_project.rb +18 -0
  126. data/app/models/foreman_pipeline/jenkins_project_param.rb +21 -0
  127. data/app/models/foreman_pipeline/jenkins_user.rb +15 -0
  128. data/app/models/foreman_pipeline/job.rb +72 -0
  129. data/app/models/foreman_pipeline/job_jenkins_project.rb +25 -0
  130. data/app/models/foreman_pipeline/job_to_environment.rb +19 -0
  131. data/app/views/foreman/unattended/snippets/_jenkins_instance_pubkey.erb +10 -0
  132. data/app/views/foreman_pipeline/api/common/async.json.rabl +3 -0
  133. data/app/views/foreman_pipeline/api/common/index.json.rabl +7 -0
  134. data/app/views/foreman_pipeline/api/compute_resources/index.json.rabl +3 -0
  135. data/app/views/foreman_pipeline/api/compute_resources/show.json.rabl +5 -0
  136. data/app/views/foreman_pipeline/api/content_views/index.json.rabl +3 -0
  137. data/app/views/foreman_pipeline/api/content_views/show.json.rabl +5 -0
  138. data/app/views/foreman_pipeline/api/environments/show.json.rabl +11 -0
  139. data/app/views/foreman_pipeline/api/hostgroups/index.json.rabl +3 -0
  140. data/app/views/foreman_pipeline/api/hostgroups/show.json.rabl +5 -0
  141. data/app/views/foreman_pipeline/api/jenkins_instances/index.json.rabl +3 -0
  142. data/app/views/foreman_pipeline/api/jenkins_instances/show.json.rabl +7 -0
  143. data/app/views/foreman_pipeline/api/jenkins_project_params/index.json.rabl +3 -0
  144. data/app/views/foreman_pipeline/api/jenkins_project_params/show.json.rabl +3 -0
  145. data/app/views/foreman_pipeline/api/jenkins_projects/index.json.rabl +3 -0
  146. data/app/views/foreman_pipeline/api/jenkins_projects/show.json.rabl +7 -0
  147. data/app/views/foreman_pipeline/api/jenkins_users/index.json.rabl +2 -0
  148. data/app/views/foreman_pipeline/api/jenkins_users/show.json.rabl +3 -0
  149. data/app/views/foreman_pipeline/api/jobs/available_paths.json.rabl +9 -0
  150. data/app/views/foreman_pipeline/api/jobs/index.json.rabl +3 -0
  151. data/app/views/foreman_pipeline/api/jobs/show.json.rabl +32 -0
  152. data/config/mount_engine.rb +3 -0
  153. data/config/routes.rb +53 -0
  154. data/db/migrate/20141003121914_create_job_table.rb +13 -0
  155. data/db/migrate/20141003145152_add_organization_to_jobs_table.rb +9 -0
  156. data/db/migrate/20141014125836_make_content_view_and_hostgroup_optional_for_job.rb +11 -0
  157. data/db/migrate/20141029121444_create_test_table.rb +11 -0
  158. data/db/migrate/20141029125423_add_organization_to_test_table.rb +9 -0
  159. data/db/migrate/20141030154210_create_jobs_tests_table.rb +12 -0
  160. data/db/migrate/20141120130350_add_resource_to_job.rb +9 -0
  161. data/db/migrate/20150121134503_create_jenkins_instances_table.rb +13 -0
  162. data/db/migrate/20150121134748_add_jenkins_instances_to_job_table.rb +9 -0
  163. data/db/migrate/20150122155819_add_kt_environment_to_jobs_table.rb +9 -0
  164. data/db/migrate/20150127101153_add_trigger_options_to_jobs_table.rb +13 -0
  165. data/db/migrate/20150202180711_add_content_column_to_tests_table.rb +9 -0
  166. data/db/migrate/20150209145400_add_pubkey_to_jenkins_instance_table.rb +9 -0
  167. data/db/migrate/20150209160604_add_jenkins_home_to_jenkins_instance_table.rb +9 -0
  168. data/db/migrate/20150212115234_add_uniqueness_to_jenkins_instance_url.rb +9 -0
  169. data/db/migrate/20150212125901_add_uniqueness_to_test_name.rb +9 -0
  170. data/db/migrate/20150213095447_add_cert_path_to_jenkins_instances.rb +9 -0
  171. data/db/migrate/20150216170951_add_build_step_to_tests_table.rb +9 -0
  172. data/db/migrate/20150223142315_change_jenkins_instance_cert_path_column.rb +9 -0
  173. data/db/migrate/20150224090100_create_jenkins_projects_table.rb +19 -0
  174. data/db/migrate/20150226182211_add_org_to_jenkins_project.rb +9 -0
  175. data/db/migrate/20150301134121_create_jenkins_project_params_table.rb +16 -0
  176. data/db/migrate/20150303134951_change_jenkins_project_param_value_column.rb +9 -0
  177. data/db/migrate/20150304123529_change_jenkins_project_params_table.rb +9 -0
  178. data/db/migrate/20150305122212_drop_tests_table.rb +5 -0
  179. data/db/migrate/20150312153833_create_jenkins_users.rb +15 -0
  180. data/db/migrate/20150313093244_add_jenkins_user_to_jobs.rb +9 -0
  181. data/db/migrate/20150313115956_change_jenkins_user_owner.rb +9 -0
  182. data/db/migrate/20150318141859_rename_tables.rb +19 -0
  183. data/db/migrate/20150323153355_remove_owner_from_jenkins_user.rb +9 -0
  184. data/db/migrate/20150323165954_add_jenkins_user_to_instance.rb +9 -0
  185. data/db/migrate/20150323175436_remove_jenkins_user_from_job.rb +9 -0
  186. data/db/migrate/20150324082437_remove_jenkins_instance_from_user.rb +9 -0
  187. data/db/migrate/20150324093416_add_promote_to_jobs.rb +9 -0
  188. data/db/migrate/20150324124034_create_job_path.rb +13 -0
  189. data/db/migrate/20150408143011_remove_cv_promote_from_job.rb +9 -0
  190. data/db/migrate/20150408145022_rename_job_path.rb +11 -0
  191. data/db/migrate/20150923073033_drop_orphaned_table.rb +8 -0
  192. data/lib/foreman_pipeline.rb +5 -0
  193. data/lib/foreman_pipeline/engine.rb +67 -0
  194. data/lib/foreman_pipeline/permissions.rb +3 -0
  195. data/lib/foreman_pipeline/permissions/jenkins_instance_permissions.rb +25 -0
  196. data/lib/foreman_pipeline/permissions/jenkins_project_params_permissions.rb +9 -0
  197. data/lib/foreman_pipeline/permissions/jenkins_projects_permissions.rb +9 -0
  198. data/lib/foreman_pipeline/permissions/jenkins_request_permissions.rb +9 -0
  199. data/lib/foreman_pipeline/permissions/jenkins_user_permissions.rb +24 -0
  200. data/lib/foreman_pipeline/permissions/job_permissions.rb +27 -0
  201. data/lib/foreman_pipeline/plugin.rb +17 -0
  202. data/lib/foreman_pipeline/roles.rb +13 -0
  203. data/lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake +18 -0
  204. data/lib/foreman_pipeline/tasks/foreman_pipeline_test.rake +34 -0
  205. data/lib/foreman_pipeline/version.rb +3 -0
  206. data/test/factories/hostgroup_factory.rb +6 -0
  207. data/test/factories/jenkins_instance_related_factory.rb +20 -0
  208. data/test/foreman_pipeline_plugin_test_helper.rb +28 -0
  209. data/test/unit/job_test.rb +26 -0
  210. data/test/unit/sanity_test.rb +12 -0
  211. metadata +327 -0
@@ -0,0 +1,9 @@
1
+ class AddOrgToJenkinsProject < ActiveRecord::Migration
2
+ def up
3
+ add_column :integration_jenkins_projects, :organization_id, :integer, :null => false
4
+ end
5
+
6
+ def down
7
+ remove_column :integration_jenkins_projects, :organization_id
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ class CreateJenkinsProjectParamsTable < ActiveRecord::Migration
2
+ def up
3
+ create_table "integration_jenkins_project_params" do |t|
4
+ t.string "type", :null => false
5
+ t.string "name", :null => false
6
+ t.text "description"
7
+ t.string "value", :null => false
8
+ t.integer "organization_id", :null => false
9
+ t.integer "job_jenkins_project_id", :null => false
10
+ end
11
+ end
12
+
13
+ def down
14
+ drop_table :integration_jenkins_project_params
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class ChangeJenkinsProjectParamValueColumn < ActiveRecord::Migration
2
+ def up
3
+ change_column :integration_jenkins_project_params, :value, :text
4
+ end
5
+
6
+ def down
7
+ change_column :integration_jenkins_project_params, :value, :string
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ChangeJenkinsProjectParamsTable < ActiveRecord::Migration
2
+ def up
3
+ rename_column :integration_jenkins_project_params, :job_jenkins_project_id, :jenkins_project_id
4
+ end
5
+
6
+ def down
7
+ rename_column :integration_jenkins_project_params, :jenkins_project_id, :job_jenkins_project_id
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class DropTestsTable < ActiveRecord::Migration
2
+ def change
3
+ drop_table :integration_tests
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ class CreateJenkinsUsers < ActiveRecord::Migration
2
+ def up
3
+ create_table "integration_jenkins_users" do |t|
4
+ t.string "name", :null => false
5
+ t.string "token", :null => false
6
+ t.integer "organization_id", :null => false
7
+ t.integer "jenkins_instance_id", :null => false
8
+ t.integer "user_id", :null => false
9
+ end
10
+ end
11
+
12
+ def down
13
+ drop_table "integration_jenkins_users"
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ class AddJenkinsUserToJobs < ActiveRecord::Migration
2
+ def up
3
+ add_column :integration_jobs, :jenkins_user_id, :integer
4
+ end
5
+
6
+ def down
7
+ remove_column :integration_jobs, :jenkins_user_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ChangeJenkinsUserOwner < ActiveRecord::Migration
2
+ def up
3
+ rename_column :integration_jenkins_users, :user_id, :owner_id
4
+ end
5
+
6
+ def down
7
+ rename_column :integration_jenkins_users, :owner_id, :user_id
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ class RenameTables < ActiveRecord::Migration
2
+ def up
3
+ rename_table :integration_jobs, :foreman_pipeline_jobs
4
+ rename_table :integration_jenkins_users, :foreman_pipeline_jenkins_users
5
+ rename_table :integration_jenkins_instances, :foreman_pipeline_jenkins_instances
6
+ rename_table :integration_jenkins_project_params, :foreman_pipeline_jenkins_project_params
7
+ rename_table :integration_jenkins_projects, :foreman_pipeline_jenkins_projects
8
+ rename_table :integration_job_jenkins_projects, :foreman_pipeline_job_jenkins_projects
9
+ end
10
+
11
+ def down
12
+ rename_table :foreman_pipeline_jobs, :integration_jobs
13
+ rename_table :foreman_pipeline_jenkins_users, :integration_jenkins_users
14
+ rename_table :foreman_pipeline_jenkins_instances, :integration_jenkins_instances
15
+ rename_table :foreman_pipeline_jenkins_project_params, :integration_jenkins_project_params
16
+ rename_table :foreman_pipeline_jenkins_projects, :integration_jenkins_projects
17
+ rename_table :foreman_pipeline_job_jenkins_projects, :integration_job_jenkins_projects
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ class RemoveOwnerFromJenkinsUser < ActiveRecord::Migration
2
+ def up
3
+ remove_column :foreman_pipeline_jenkins_users, :owner_id
4
+ end
5
+
6
+ def down
7
+ add_column :foreman_pipeline_jenkins_users, :owner_id, :integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddJenkinsUserToInstance < ActiveRecord::Migration
2
+ def up
3
+ add_column :foreman_pipeline_jenkins_instances, :jenkins_user_id, :integer
4
+ end
5
+
6
+ def down
7
+ remove_column :foreman_pipeline_jenkins_instances, :jenkins_user_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class RemoveJenkinsUserFromJob < ActiveRecord::Migration
2
+ def up
3
+ remove_column :foreman_pipeline_jobs, :jenkins_user_id
4
+ end
5
+
6
+ def down
7
+ add_column :foreman_pipeline_jobs, :jenkins_user_id, :integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class RemoveJenkinsInstanceFromUser < ActiveRecord::Migration
2
+ def up
3
+ remove_column :foreman_pipeline_jenkins_users, :jenkins_instance_id
4
+ end
5
+
6
+ def down
7
+ add_column :foreman_pipeline_jenkins_users, :jenkins_instance_id, :integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddPromoteToJobs < ActiveRecord::Migration
2
+ def up
3
+ add_column :foreman_pipeline_jobs, :promote, :boolean, :default => false
4
+ end
5
+
6
+ def down
7
+ remove_column :foreman_pipeline_jobs, :promote
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateJobPath < ActiveRecord::Migration
2
+ def up
3
+ create_table :foreman_pipeline_job_paths do |t|
4
+ t.integer "job_id"
5
+ t.integer "path_id"
6
+ t.integer "organization_id"
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :foreman_pipeline_job_paths
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class RemoveCvPromoteFromJob < ActiveRecord::Migration
2
+ def up
3
+ remove_column :foreman_pipeline_jobs, :promote
4
+ end
5
+
6
+ def down
7
+ add_column :foreman_pipeline_jobs, :promote, :boolean, :default => false
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class RenameJobPath < ActiveRecord::Migration
2
+ def up
3
+ rename_table :foreman_pipeline_job_paths, :foreman_pipeline_job_to_environments
4
+ rename_column :foreman_pipeline_job_to_environments, :path_id, :to_environment_id
5
+ end
6
+
7
+ def down
8
+ rename_table :foreman_pipeline_job_to_environments, :foreman_pipeline_job_paths
9
+ rename_column :foreman_pipeline_job_paths, :to_environment_id , :path_id
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ class DropOrphanedTable < ActiveRecord::Migration
2
+ def up
3
+ drop_table :integration_jobs_tests
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ require "foreman_pipeline/engine"
2
+
3
+ module ForemanPipeline
4
+ require "#{ForemanPipeline::Engine.root}/app/lib/foreman_pipeline/api/rendering"
5
+ end
@@ -0,0 +1,67 @@
1
+ module ForemanPipeline
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ForemanPipeline
4
+ require 'foreman_deployments'
5
+
6
+ initializer 'foreman_pipeline.mount_engine', :after => :build_middleware_stack do |app|
7
+ app.routes_reloader.paths << "#{ForemanPipeline::Engine.root}/config/mount_engine.rb"
8
+ end
9
+
10
+ initializer 'foreman_pipeline.load_app_instance_data' do |app|
11
+ app.config.paths['db/migrate'] += ForemanPipeline::Engine.paths['db/migrate'].existent
12
+ app.config.autoload_paths += Dir["#{config.root}/app/lib"]
13
+ app.config.autoload_paths += Dir["#{config.root}/app/views/foreman"]
14
+ end
15
+
16
+ initializer 'foreman_pipeline.register_plugin', :after => :finisher_hook do
17
+ require 'foreman_pipeline/plugin'
18
+ require 'foreman_pipeline/permissions'
19
+ require 'foreman_pipeline/roles'
20
+ end
21
+
22
+ initializer 'foreman_pipeline.assets', :group => :all do |app|
23
+ SETTINGS[:foreman_pipeline] = {
24
+ :assets => {
25
+ :precompile => [
26
+ 'foreman_pipeline/foreman_pipeline.js'
27
+ ]
28
+ }
29
+ }
30
+ end
31
+
32
+ initializer 'foreman_pipeline.register_actions', :before => 'foreman_tasks.initialize_dynflow' do |app|
33
+ ForemanTasks.dynflow.require!
34
+
35
+ action_paths = %W(#{ForemanPipeline::Engine.root}/app/lib/actions)
36
+
37
+ ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
38
+ end
39
+
40
+ config.to_prepare do
41
+
42
+ Bastion.register_plugin({
43
+ :name => 'foreman_pipeline',
44
+ :javascript => 'foreman_pipeline/foreman_pipeline',
45
+ :stylesheet => 'foreman_pipeline/foreman_pipeline',
46
+ :pages => %w(
47
+ jobs
48
+ jenkins_instances
49
+ )
50
+ })
51
+
52
+ # extensions
53
+ ::Katello::Repository.send :include, ForemanPipeline::Concerns::RepositoryExtension
54
+ ::Katello::ContentViewRepository.send :include, ForemanPipeline::Concerns::ContentViewRepositoryExtension
55
+ ::Katello::ContentView.send :include, ForemanPipeline::Concerns::ContentViewExtension
56
+ ::Katello::KTEnvironment.send :include, ForemanPipeline::Concerns::KtEnvironmentExtension
57
+ ::Hostgroup.send :include, ForemanPipeline::Concerns::HostgroupExtension
58
+ ::ComputeResource.send :include, ForemanPipeline::Concerns::ComputeResourceExtension
59
+ end
60
+
61
+ rake_tasks do
62
+ load "#{ForemanPipeline::Engine.root}/lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake"
63
+ load "#{ForemanPipeline::Engine.root}/lib/foreman_pipeline/tasks/foreman_pipeline_test.rake"
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ Dir["#{File.expand_path('../permissions', __FILE__)}/*.rb"].each do |file|
2
+ require file
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ Foreman::Plugin.find(:foreman_pipeline).security_block :jenkins_instances do
4
+ permission :view_jenkins_instances,
5
+ {
6
+ 'foreman_pipeline/jenkins_instances' => [:all, :index, :show],
7
+ 'foreman_pipeline/api/jenkins_instances' => [:index, :show, :check_jenkins],
8
+ },
9
+ :resource_type => 'ForemanPipeline::JenkinsInstance'
10
+ permission :create_jenkins_instances,
11
+ {
12
+ 'foreman_pipeline/api/jenkins_instances' => [:create],
13
+ },
14
+ :resource_type => 'ForemanPipeline::JenkinsInstance'
15
+ permission :edit_jenkins_instances,
16
+ {
17
+ 'foreman_pipeline/api/jenkins_instances' => [:update, :set_jenkins_user],
18
+ },
19
+ :resource_type => 'ForemanPipeline::JenkinsInstance'
20
+ permission :destroy_jenkins_instances,
21
+ {
22
+ 'foreman_pipeline/api/jenkins_instances' => [:destroy],
23
+ },
24
+ :resource_type => 'ForemanPipeline::JenkinsInstance'
25
+ end
@@ -0,0 +1,9 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ Foreman::Plugin.find(:foreman_pipeline).security_block :jenkins_project_params do
4
+ permission :edit_jenkins_project_params,
5
+ {
6
+ 'foreman_pipeline/api/jenkins_project_params' => [:update],
7
+ },
8
+ :resource_type => 'ForemanPipeline::JenkinsProjectParam'
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ Foreman::Plugin.find(:foreman_pipeline).security_block :jenkins_projects do
4
+ permission :view_jenkins_projects,
5
+ {
6
+ 'foreman_pipeline/api/jenkins_projects' => [:show],
7
+ },
8
+ :resource_type => 'ForemanPipeline::JenkinsProject'
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ Foreman::Plugin.find(:foreman_pipeline).security_block :jenkins_requests do
4
+ permission :view_jenkins_requests,
5
+ {
6
+ 'foreman_pipeline/api/jenkins_requests' => [:list],
7
+ },
8
+ :resource_type => 'ForemanPipeline::JenkinsProject'
9
+ end
@@ -0,0 +1,24 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ Foreman::Plugin.find(:foreman_pipeline).security_block :jenkins_users do
4
+ permission :view_jenkins_users,
5
+ {
6
+ 'foreman_pipeline/api/jenkins_users' => [:index, :show]
7
+ },
8
+ :resource_type => 'ForemanPipeline::JenkinsUser'
9
+ permission :create_jenkins_users,
10
+ {
11
+ 'foreman_pipeline/api/jenkins_users' => [:create]
12
+ },
13
+ :resource_type => 'ForemanPipeline::JenkinsUser'
14
+ permission :edit_jenkins_users,
15
+ {
16
+ 'foreman_pipeline/api/jenkins_users' => [:update]
17
+ },
18
+ :resource_type => 'ForemanPipeline::JenkinsUser'
19
+ permission :destroy_jenkins_users,
20
+ {
21
+ 'foreman_pipeline/api/jenkins_users' => [:destroy]
22
+ },
23
+ :resource_type => 'ForemanPipeline::JenkinsUser'
24
+ end
@@ -0,0 +1,27 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ Foreman::Plugin.find(:foreman_pipeline).security_block :jobs do
4
+ permission :view_jobs,
5
+ {
6
+ 'foreman_pipeline/jobs' => [:all, :index, :show],
7
+ 'foreman_pipeline/api/jobs' => [:index, :show, :available_paths, :available_resources],
8
+ },
9
+ :resource_type => 'ForemanPipeline::Job'
10
+ permission :create_jobs,
11
+ {
12
+ 'foreman_pipeline/api/jobs' => [:create],
13
+ },
14
+ :resource_type => 'ForemanPipeline::Job'
15
+ permission :edit_jobs,
16
+ {
17
+ 'foreman_pipeline/api/jobs' => [:update, :set_content_view, :set_hostgroup, :set_jenkins,
18
+ :set_environment, :set_resource, :set_to_environments, :run_job,
19
+ :add_projects, :remove_projects],
20
+ },
21
+ :resource_type => 'ForemanPipeline::Job'
22
+ permission :destroy_jobs,
23
+ {
24
+ 'foreman_pipeline/api/jobs' => [:destroy],
25
+ },
26
+ :resource_type => 'ForemanPipeline::Job'
27
+ end
@@ -0,0 +1,17 @@
1
+ Foreman::Plugin.register :foreman_pipeline do
2
+
3
+ sub_menu :top_menu, :foreman_pipeline_menu, :caption => N_('Pipeline') do
4
+ menu :top_menu,
5
+ :jobs,
6
+ :caption => N_("Jobs"),
7
+ :url => '/jobs',
8
+ :url_hash => {:controller => 'foreman_pipeline/api/jobs', :action => 'index'},
9
+ :engine => ForemanPipeline::Engine
10
+ menu :top_menu,
11
+ :jenkins_instances,
12
+ :caption => N_("Jenkins Instances"),
13
+ :url => '/jenkins_instances',
14
+ :url_hash => {:controller => 'foreman_pipeline/api/jenkins_instances', :action => 'index'},
15
+ :engine => ForemanPipeline::Engine
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require 'foreman_pipeline/plugin'
2
+
3
+ viewer_permissions = [:view_jobs, :view_jenkins_instances, :view_jenkins_users,
4
+ :view_jenkins_projects, :view_jenkins_requests]
5
+ manager_permissions = [:view_jobs, :edit_jobs, :destroy_jobs, :create_jobs,
6
+ :view_jenkins_instances, :edit_jenkins_instances, :destroy_jenkins_instances, :create_jenkins_instances,
7
+ :view_jenkins_users, :edit_jenkins_users, :destroy_jenkins_users, :create_jenkins_users,
8
+ :view_jenkins_projects,
9
+ :edit_jenkins_project_params,
10
+ :view_jenkins_requests]
11
+
12
+ Foreman::Plugin.find(:foreman_pipeline).send :role, "Pipeline viewer", viewer_permissions
13
+ Foreman::Plugin.find(:foreman_pipeline).send :role, "Pipeline manager", manager_permissions