autoproj-jenkins 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5d96120cc78350275e92584c61af35c413bcafb
4
- data.tar.gz: d1bd6d3060ea76972df27145c9fceed592354ba9
3
+ metadata.gz: e92a3c5e2fa195e68aa458ede6b7b9c3bd3f368b
4
+ data.tar.gz: 29128926f9dffaade30fbb54f81d932feddeba4b
5
5
  SHA512:
6
- metadata.gz: 6d3f538eac2dd5471fb6bcf43f5f788e7babbe67ce8ced5edc8cc73a10eefeeece7e57dc9c55eacf37c2ebbac9b38ee27b2eec1e8112a78ef14fd28ad883e80d
7
- data.tar.gz: 31525d9641c6df34e2b1b41af1700d3436381ca40bdacb3a4ec1b8b145598babbee284c4def436bb58d686ef721c3e89cf2f7d11da01be6e5682642846bd5e3e
6
+ metadata.gz: 62d363e754695d26b6f26e3ae43813c5513efd03679616347b966c98c1851524096d0c4b0776186daca6672ab0d60f45f67d20932445ff85a5aeff58f137a332
7
+ data.tar.gz: 786f2c9443ff314e25a7b61c8517998d8381c73801336c62f79ec7b1a5dab32973a29b8d79f3478f44887430f8fb94f3ff35699711151afdea1bb39c923f8d52
@@ -22,7 +22,7 @@ module Autoproj
22
22
  results
23
23
  end
24
24
 
25
- def create_or_update_buildconf_job(*package_names, force: false, dev: false, credentials_id: nil, vcs_credentials: [])
25
+ def create_or_update_buildconf_job(*package_names, dev: false, credentials_id: nil, vcs_credentials: [])
26
26
  initialize_and_load
27
27
 
28
28
  if dev
@@ -42,7 +42,7 @@ module Autoproj
42
42
 
43
43
  def add_or_update_packages(*package_names, dev: false, vcs_credentials: [])
44
44
  initialize_and_load
45
- source_packages, _ = finalize_setup(package_names, non_imported_packages: nil)
45
+ source_packages, _ = finalize_setup(package_names, non_imported_packages: :ignore)
46
46
  source_packages = source_packages.map do |package_name|
47
47
  ws.manifest.package_definition_by_name(package_name)
48
48
  end
@@ -49,7 +49,6 @@ module Autoproj
49
49
  end
50
50
 
51
51
  desc 'init URL [PACKAGE NAMES]', 'initialize the jenkins server by creating the base build job, optionally restricting the build to certain packages'
52
- option :force, desc: 'if set, delete any existing job'
53
52
  option :trigger, desc: 'trigger the job once created',
54
53
  type: :boolean, default: false
55
54
  option :dev, desc: 'assume that the jenkins instance is a development instance under vagrant and that autoproj-jenkins is made available as /opt/autoproj-jenkins',
@@ -67,7 +66,6 @@ module Autoproj
67
66
  ops.create_or_update_buildconf_job(
68
67
  *package_names,
69
68
  credentials_id: options[:credentials_id],
70
- force: options[:force],
71
69
  vcs_credentials: options[:vcs_credentials],
72
70
  dev: options[:dev])
73
71
  if options[:trigger]
@@ -77,7 +75,6 @@ module Autoproj
77
75
 
78
76
 
79
77
  desc 'update [PACKAGE_NAMES]', 'add the following package and its dependencies to the jenkins build'
80
- option :force, desc: 'ignore the current state, generate jobs as if nothing was ever done'
81
78
  option :dev, desc: 'assume that the jenkins instance is a development instance under vagrant and that autoproj-jenkins is made available as /opt/autoproj-jenkins',
82
79
  type: :boolean, default: false
83
80
  option :vcs_credentials, desc: 'list of vcs_type:URLs for which credentials should be provided (see documentation)',
@@ -27,6 +27,28 @@ module Autoproj::Jenkins
27
27
  jobs.create(job_name, xml)
28
28
  end
29
29
 
30
+ # Reset the configuration of an existing job
31
+ #
32
+ # @param [String] job_name the name of the new job
33
+ # @param [String] template the name of the template
34
+ # @param [Hash] parameters parameters for the template rendering
35
+ # @raise (see Autoproj::Jenkins.render_template)
36
+ def reset_job(job_name, template, **parameters)
37
+ xml = Autoproj::Jenkins.render_template(template, **parameters)
38
+ jobs.update(job_name, xml)
39
+ end
40
+
41
+ # Either create or reset a job, depending on whether it already exists
42
+ # or not
43
+ def create_or_reset_job(job_name, template, **parameters)
44
+ xml = Autoproj::Jenkins.render_template(template, **parameters)
45
+ if has_job?(job_name)
46
+ reset_job(job_name, template, **parameters)
47
+ else
48
+ create_job(job_name, template, **parameters)
49
+ end
50
+ end
51
+
30
52
  # Test whether the server already has a job
31
53
  #
32
54
  # @param [String] job_name
@@ -3,7 +3,6 @@
3
3
  <actions/>
4
4
  <description></description>
5
5
  <keepDependencies>false</keepDependencies>
6
- <properties/>
7
6
  <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.9">
8
7
  <script>
9
8
  </script>
@@ -11,14 +10,24 @@
11
10
  </definition>
12
11
  <triggers/>
13
12
  <quietPeriod><%= quiet_period %></quietPeriod>
14
- <jenkins.model.BuildDiscarderProperty>
15
- <strategy class="hudson.tasks.LogRotator">
16
- <daysToKeep>30</daysToKeep>
17
- <numToKeep>-1</numToKeep>
18
- <artifactDaysToKeep>7</artifactDaysToKeep>
19
- <artifactNumToKeep>-1</artifactNumToKeep>
20
- </strategy>
21
- </jenkins.model.BuildDiscarderProperty>
13
+ <properties>
14
+ <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
15
+ <triggers>
16
+ <hudson.triggers.SCMTrigger>
17
+ <spec>H/30 * * * *</spec>
18
+ <ignorePostCommitHooks>false</ignorePostCommitHooks>
19
+ </hudson.triggers.SCMTrigger>
20
+ </triggers>
21
+ </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
22
+ <jenkins.model.BuildDiscarderProperty>
23
+ <strategy class="hudson.tasks.LogRotator">
24
+ <daysToKeep>30</daysToKeep>
25
+ <numToKeep>-1</numToKeep>
26
+ <artifactDaysToKeep>10</artifactDaysToKeep>
27
+ <artifactNumToKeep>-1</artifactNumToKeep>
28
+ </strategy>
29
+ </jenkins.model.BuildDiscarderProperty>
30
+ </properties>
22
31
  </flow-definition>
23
32
 
24
33
 
@@ -36,16 +36,6 @@ module Autoproj::Jenkins
36
36
  @job_prefix = job_prefix
37
37
  end
38
38
 
39
- # Create the master buildconf job
40
- #
41
- # @return [void]
42
- def create_buildconf_job(force: false, quiet_period: 5)
43
- if force
44
- server.delete_job("#{job_prefix}buildconf")
45
- end
46
- server.create_job("#{job_prefix}buildconf", 'buildconf.xml', quiet_period: quiet_period)
47
- end
48
-
49
39
  # Update the buildconf pipeline
50
40
  #
51
41
  # @param [String] jenkins_url the URL of the jenkins server from the
@@ -66,7 +56,8 @@ module Autoproj::Jenkins
66
56
  raise ArgumentError, "cannot use Jenkins to build an autoproj buildconf that is not on a remotely acessible VCS"
67
57
  end
68
58
 
69
- server.update_job_pipeline("#{job_prefix}buildconf", 'buildconf.pipeline',
59
+ job_name = job_name_from_package_name("buildconf")
60
+ server.update_job_pipeline(job_name, 'buildconf.pipeline',
70
61
  vcs: manifest_vcs,
71
62
  package_names: package_names,
72
63
  gemfile: gemfile,
@@ -87,10 +78,9 @@ module Autoproj::Jenkins
87
78
  # @param [Integer] quiet_period the job's quiet period, in seconds.
88
79
  # Mostly used within autoproj-jenkins tests
89
80
  def create_or_update_buildconf_job(*packages, gemfile: 'buildconf-Gemfile', autoproj_install_path: nil, dev: false, quiet_period: 5, credentials_id: nil, vcs_credentials: Credentials.new)
90
- job_name = "#{job_prefix}buildconf"
91
- if !server.has_job?(job_name)
92
- create_buildconf_job(quiet_period: quiet_period)
93
- end
81
+ job_name = job_name_from_package_name("buildconf")
82
+ server.create_or_reset_job(job_name, 'buildconf.xml', quiet_period: quiet_period)
83
+
94
84
  update_buildconf_pipeline(
95
85
  *packages,
96
86
  gemfile: gemfile,
@@ -108,18 +98,6 @@ module Autoproj::Jenkins
108
98
  "#{job_prefix}#{package_name.gsub('/', '-')}"
109
99
  end
110
100
 
111
- # Create a job for a package
112
- #
113
- # @return [void]
114
- def create_package_job(package, job_name: job_name_from_package_name(package.name), force: false, quiet_period: 5)
115
- job_name = job_name_from_package_name(package.name)
116
- if force
117
- server.delete_job(job_name)
118
- end
119
-
120
- server.create_job(job_name, 'package.xml', quiet_period: quiet_period)
121
- end
122
-
123
101
  # Resolve a package by its name
124
102
  def package_by_name(package_name)
125
103
  package = ws.manifest.find_package_definition(package_name)
@@ -171,9 +149,9 @@ module Autoproj::Jenkins
171
149
 
172
150
  packages.each do |package|
173
151
  job_name = job_name_from_package_name(package.name)
174
- if !server.has_job?(job_name)
175
- create_package_job(package, job_name: job_name, quiet_period: quiet_period)
176
- end
152
+ server.create_or_reset_job(
153
+ job_name, 'package.xml',
154
+ job_name: job_name, quiet_period: quiet_period)
177
155
  end
178
156
 
179
157
  package_names = packages.map(&:name).to_set
@@ -1,5 +1,5 @@
1
1
  module Autoproj
2
2
  module Jenkins
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj-jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jenkins_api_client
@@ -176,4 +176,3 @@ signing_key:
176
176
  specification_version: 4
177
177
  summary: Exporting an autoproj build to a jenkins server
178
178
  test_files: []
179
- has_rdoc: