jenkins-capistrano 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +73 -16
- data/Gemfile.lock +80 -0
- data/README.md +169 -56
- data/Vagrantfile +23 -0
- data/example/Gemfile +3 -1
- data/example/README.md +13 -17
- data/example/config/deploy.rb +8 -12
- data/example/config/deploy/develop.rb +5 -3
- data/example/config/deploy/production.rb +13 -3
- data/example/config/deploy/staging.rb +13 -4
- data/example/config/jenkins/nodes/develop/dev-slave01.xml.erb +33 -0
- data/example/config/jenkins/nodes/production/prod-slave01.xml.erb +33 -0
- data/example/config/jenkins/nodes/production/prod-slave02.xml.erb +33 -0
- data/example/config/jenkins/nodes/production/prod-slave03.xml.erb +33 -0
- data/example/config/jenkins/nodes/staging/stg-slave01.xml.erb +33 -0
- data/example/config/jenkins/nodes/staging/stg-slave02.xml.erb +33 -0
- data/example/config/jenkins/nodes/staging/stg-slave03.xml.erb +33 -0
- data/example/script/bootstrap +1 -2
- data/features/config_jobs.feature +162 -0
- data/features/config_nodes.feature +121 -0
- data/features/config_views.feature +136 -0
- data/features/help.feature +83 -0
- data/features/step_definitions/jenkins_steps.rb +19 -0
- data/features/support/env.rb +5 -0
- data/features/support/jenkins_helper.rb +113 -0
- data/jenkins-capistrano.gemspec +4 -3
- data/lib/jenkins-capistrano.rb +2 -215
- data/lib/jenkins-capistrano/configurator.rb +87 -0
- data/lib/jenkins-capistrano/tasks.rb +112 -0
- data/lib/jenkins-capistrano/template.rb +20 -0
- data/lib/jenkins-capistrano/version.rb +1 -1
- metadata +87 -41
- checksums.yaml +0 -7
- data/example/config/jenkins/jobs/.gitkeep +0 -0
- data/example/config/jenkins/nodes/develop/dev-slave01.json +0 -17
- data/example/config/jenkins/nodes/production/prod-slave01.json +0 -17
- data/example/config/jenkins/nodes/production/prod-slave02.json +0 -17
- data/example/config/jenkins/nodes/production/prod-slave03.json +0 -17
- data/example/config/jenkins/nodes/staging/stg-slave01.json +0 -17
- data/example/config/jenkins/nodes/staging/stg-slave02.json +0 -17
- data/example/config/jenkins/nodes/staging/stg-slave03.json +0 -17
- data/lib/jenkins-capistrano/client.rb +0 -66
- data/lib/jenkins-capistrano/client/job.rb +0 -47
- data/lib/jenkins-capistrano/client/node.rb +0 -103
- data/lib/jenkins-capistrano/client/plugin_manager.rb +0 -51
- data/lib/jenkins-capistrano/client/update_center.rb +0 -43
- data/lib/jenkins-capistrano/client/view.rb +0 -40
data/.gitignore
CHANGED
@@ -1,18 +1,75 @@
|
|
1
|
+
# Created by http://www.gitignore.io
|
2
|
+
|
3
|
+
### Ruby ###
|
1
4
|
*.gem
|
2
5
|
*.rbc
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
/example/Gemfile.lock
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
|
21
|
+
## Documentation cache and generated files:
|
22
|
+
/.yardoc/
|
23
|
+
/_yardoc/
|
24
|
+
/doc/
|
25
|
+
/rdoc/
|
26
|
+
|
27
|
+
## Environment normalisation:
|
28
|
+
/.bundle/
|
29
|
+
/lib/bundler/man/
|
30
|
+
|
31
|
+
# for a library or gem, you might want to ignore these files since the code is
|
32
|
+
# intended to run in multiple environments; otherwise, check them in:
|
33
|
+
# Gemfile.lock
|
34
|
+
# .ruby-version
|
35
|
+
# .ruby-gemset
|
36
|
+
|
37
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
38
|
+
.rvmrc
|
39
|
+
|
40
|
+
|
41
|
+
### OSX ###
|
42
|
+
.DS_Store
|
43
|
+
.AppleDouble
|
44
|
+
.LSOverride
|
45
|
+
|
46
|
+
# Icon must end with two \r
|
47
|
+
Icon
|
48
|
+
|
49
|
+
# Thumbnails
|
50
|
+
._*
|
51
|
+
|
52
|
+
# Files that might appear on external disk
|
53
|
+
.Spotlight-V100
|
54
|
+
.Trashes
|
55
|
+
|
56
|
+
# Directories potentially created on remote AFP share
|
57
|
+
.AppleDB
|
58
|
+
.AppleDesktop
|
59
|
+
Network Trash Folder
|
60
|
+
Temporary Items
|
61
|
+
.apdisk
|
62
|
+
|
63
|
+
|
64
|
+
### Vagrant ###
|
65
|
+
.vagrant/
|
66
|
+
|
67
|
+
|
68
|
+
### vim ###
|
69
|
+
[._]*.s[a-w][a-z]
|
70
|
+
[._]s[a-w][a-z]
|
71
|
+
*.un~
|
72
|
+
Session.vim
|
73
|
+
.netrwhist
|
74
|
+
*~
|
75
|
+
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jenkins-capistrano (0.1.0)
|
5
|
+
capistrano (< 3.0.0)
|
6
|
+
jenkins_api_client (>= 1.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
aruba (0.5.4)
|
12
|
+
childprocess (>= 0.3.6)
|
13
|
+
cucumber (>= 1.1.1)
|
14
|
+
rspec-expectations (>= 2.7.0)
|
15
|
+
builder (3.2.2)
|
16
|
+
capistrano (2.15.5)
|
17
|
+
highline
|
18
|
+
net-scp (>= 1.0.0)
|
19
|
+
net-sftp (>= 2.0.0)
|
20
|
+
net-ssh (>= 2.0.14)
|
21
|
+
net-ssh-gateway (>= 1.1.0)
|
22
|
+
childprocess (0.5.3)
|
23
|
+
ffi (~> 1.0, >= 1.0.11)
|
24
|
+
coderay (1.1.0)
|
25
|
+
cucumber (1.3.15)
|
26
|
+
builder (>= 2.1.2)
|
27
|
+
diff-lcs (>= 1.1.3)
|
28
|
+
gherkin (~> 2.12)
|
29
|
+
multi_json (>= 1.7.5, < 2.0)
|
30
|
+
multi_test (>= 0.1.1)
|
31
|
+
diff-lcs (1.2.5)
|
32
|
+
ffi (1.9.3)
|
33
|
+
gherkin (2.12.2)
|
34
|
+
multi_json (~> 1.3)
|
35
|
+
highline (1.6.21)
|
36
|
+
jenkins_api_client (1.0.0)
|
37
|
+
json
|
38
|
+
mixlib-shellout (>= 1.1.0)
|
39
|
+
nokogiri (~> 1.6.0)
|
40
|
+
terminal-table (>= 1.4.0)
|
41
|
+
thor (>= 0.16.0)
|
42
|
+
json (1.8.1)
|
43
|
+
method_source (0.8.2)
|
44
|
+
mini_portile (0.6.0)
|
45
|
+
mixlib-shellout (1.4.0)
|
46
|
+
multi_json (1.10.1)
|
47
|
+
multi_test (0.1.1)
|
48
|
+
net-scp (1.2.1)
|
49
|
+
net-ssh (>= 2.6.5)
|
50
|
+
net-sftp (2.1.2)
|
51
|
+
net-ssh (>= 2.6.5)
|
52
|
+
net-ssh (2.9.1)
|
53
|
+
net-ssh-gateway (1.2.0)
|
54
|
+
net-ssh (>= 2.6.5)
|
55
|
+
nokogiri (1.6.2.1)
|
56
|
+
mini_portile (= 0.6.0)
|
57
|
+
pry (0.10.0)
|
58
|
+
coderay (~> 1.1.0)
|
59
|
+
method_source (~> 0.8.1)
|
60
|
+
slop (~> 3.4)
|
61
|
+
rake (10.3.2)
|
62
|
+
rspec-expectations (3.0.2)
|
63
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
+
rspec-support (~> 3.0.0)
|
65
|
+
rspec-support (3.0.2)
|
66
|
+
slop (3.5.0)
|
67
|
+
tapp (1.4.0)
|
68
|
+
thor
|
69
|
+
terminal-table (1.4.5)
|
70
|
+
thor (0.19.1)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
aruba
|
77
|
+
jenkins-capistrano!
|
78
|
+
pry
|
79
|
+
rake
|
80
|
+
tapp
|
data/README.md
CHANGED
@@ -1,29 +1,56 @@
|
|
1
1
|
# jenkins-capistrano
|
2
2
|
|
3
|
-
|
3
|
+
**Note**: 0.1.0 has incompatible change for Node creation.
|
4
|
+
see [Release Notes](#release-notes) and [Node Configuration](#node-configuration) for detail.
|
5
|
+
|
6
|
+
#### Table of Contents
|
7
|
+
|
8
|
+
1. [Overview](#overview)
|
9
|
+
1. [Installation](#installation)
|
10
|
+
1. [Usage](#usage)
|
11
|
+
* [Job Configuration](#job-configuration)
|
12
|
+
* [Disabling Jobs](#disabling-jobs)
|
13
|
+
* [Node Configuration](#node-configuraton)
|
14
|
+
* [Note for the Credentials Plugin and multistage-extension]()
|
15
|
+
* [View Configuration](#view-configuraton)
|
16
|
+
1. [Don't know how to write config.xml?](#dont-know-how-to-write-configxml)
|
17
|
+
1. [Known Issues](#known-issues)
|
18
|
+
* [Using mutlibyte characters in config.xml](#using-multibyte-characters-in-configxml)
|
19
|
+
1. [Todo](#todo)
|
20
|
+
1. [Release Notes](#release-notes)
|
21
|
+
1. [Contributing](#contributing)
|
22
|
+
|
23
|
+
## Overview
|
24
|
+
|
25
|
+
The capistrano tasks for Jenkins CI Server which manages following things:
|
4
26
|
|
5
27
|
* Job
|
6
28
|
* Node
|
7
29
|
* View
|
8
|
-
* Plugins(Experimental)
|
9
30
|
|
10
31
|
## Installation
|
11
32
|
|
12
33
|
Add this line to your application's Gemfile::
|
13
34
|
|
14
|
-
|
35
|
+
```
|
36
|
+
gem 'jenkins-capistrano'
|
37
|
+
```
|
15
38
|
|
16
39
|
And then execute::
|
17
40
|
|
18
|
-
|
41
|
+
```
|
42
|
+
$ bundle
|
43
|
+
```
|
19
44
|
|
20
45
|
Or install it yourself as::
|
21
46
|
|
22
|
-
|
47
|
+
```
|
48
|
+
$ gem install jenkins-capistrano
|
49
|
+
```
|
23
50
|
|
24
|
-
##
|
51
|
+
## Usage
|
25
52
|
|
26
|
-
See
|
53
|
+
See example directory or following instructions.
|
27
54
|
|
28
55
|
### Job Configuration
|
29
56
|
|
@@ -54,7 +81,7 @@ set :jenkins_host, 'http://localhost:8080'
|
|
54
81
|
before 'deploy', 'jenkins:deploy_jobs'
|
55
82
|
```
|
56
83
|
|
57
|
-
####
|
84
|
+
#### Disabling Jobs
|
58
85
|
|
59
86
|
Since 0.0.5, you can disabling jobs using `disabled_jobs` option.
|
60
87
|
Use this option with [multistage-extension](<https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension>).
|
@@ -64,7 +91,6 @@ Put the following line into `config/deploy/<env>.rb`:
|
|
64
91
|
set :disabled_jobs, %w(job1 job2)
|
65
92
|
```
|
66
93
|
|
67
|
-
|
68
94
|
### Node Configuration
|
69
95
|
|
70
96
|
config directory structure(name your json file as a node name):
|
@@ -73,32 +99,46 @@ config
|
|
73
99
|
├── deploy.rb
|
74
100
|
└── jenkins
|
75
101
|
└── nodes
|
76
|
-
├── node1.
|
77
|
-
├── node2.
|
78
|
-
└── node3.
|
102
|
+
├── node1.xml
|
103
|
+
├── node2.xml
|
104
|
+
└── node3.xml
|
79
105
|
```
|
80
106
|
|
81
107
|
sample node configuration:
|
82
|
-
```
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
"
|
91
|
-
"
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
108
|
+
```xml
|
109
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
110
|
+
<slave>
|
111
|
+
<name>example</name>
|
112
|
+
<description/>
|
113
|
+
<remoteFS>/home/jenkins</remoteFS>
|
114
|
+
<numExecutors>5</numExecutors>
|
115
|
+
<mode>EXCLUSIVE</mode>
|
116
|
+
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
|
117
|
+
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@1.5">
|
118
|
+
<host>dev-slave01.local</host>
|
119
|
+
<port>22</port>
|
120
|
+
<credentialsId>CREDENTIAL-ID-FOR-SLAVE</credentialsId>
|
121
|
+
<jvmOptions>-Dfile.encoding=UTF-8</jvmOptions>
|
122
|
+
</launcher>
|
123
|
+
<label>hello</label>
|
124
|
+
<nodeProperties>
|
125
|
+
<hudson.slaves.EnvironmentVariablesNodeProperty>
|
126
|
+
<envVars serialization="custom">
|
127
|
+
<unserializable-parents/>
|
128
|
+
<tree-map>
|
129
|
+
<default>
|
130
|
+
<comparator class="hudson.util.CaseInsensitiveComparator"/>
|
131
|
+
</default>
|
132
|
+
<int>2</int><!-- must specify env var count -->
|
133
|
+
<string>LANG</string>
|
134
|
+
<string>ja_JP.UTF-8</string>
|
135
|
+
<string>ENVIRONMENT</string>
|
136
|
+
<string>develop</string>
|
137
|
+
</tree-map>
|
138
|
+
</envVars>
|
139
|
+
</hudson.slaves.EnvironmentVariablesNodeProperty>
|
140
|
+
</nodeProperties>
|
141
|
+
</slave>
|
102
142
|
```
|
103
143
|
|
104
144
|
deploy.rb:
|
@@ -115,6 +155,62 @@ set :jenkins_host, 'http://localhost:8080'
|
|
115
155
|
before 'deploy', 'jenkins:config_nodes'
|
116
156
|
```
|
117
157
|
|
158
|
+
#### Note for the Credentials Plugin and multistage-extension
|
159
|
+
|
160
|
+
Recently, Jenkins has changed the slave's auth method to use
|
161
|
+
[Credentials Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin),
|
162
|
+
and we need to use its id(credentialsId) to create slave configuration.
|
163
|
+
However, Credentials Plugin doesn't have a REST interface to manage their credentials,
|
164
|
+
and credentialsId is different on every Jenkins master.
|
165
|
+
|
166
|
+
So, if you want to use same config.xml against different masters,
|
167
|
+
use the ERB template support to specify correct credentialsId like as following:
|
168
|
+
|
169
|
+
config/jenkins/nodes/node1.xml.erb:
|
170
|
+
```xml
|
171
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
172
|
+
<slave>
|
173
|
+
<name>batch-slave</name>
|
174
|
+
<description/>
|
175
|
+
<remoteFS>/home/jenkins</remoteFS>
|
176
|
+
<numExecutors>5</numExecutors>
|
177
|
+
<mode>EXCLUSIVE</mode>
|
178
|
+
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
|
179
|
+
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@1.5">
|
180
|
+
<host>batch-slave</host>
|
181
|
+
<port>22</port>
|
182
|
+
<credentialsId><%= @credential_id %></credentialsId>
|
183
|
+
<jvmOptions>-Dfile.encoding=UTF-8</jvmOptions>
|
184
|
+
</launcher>
|
185
|
+
<label>hello</label>
|
186
|
+
<nodeProperties/>
|
187
|
+
</slave>
|
188
|
+
```
|
189
|
+
|
190
|
+
config/deploy.rb
|
191
|
+
```ruby
|
192
|
+
set :application, "your-awesome-app"
|
193
|
+
set :scm, :git
|
194
|
+
set :repository, "https://github.com/your/repository.git"
|
195
|
+
|
196
|
+
set :jenkins_host, 'http://localhost:8080'
|
197
|
+
before 'deploy', 'jenkins:config_nodes'
|
198
|
+
```
|
199
|
+
|
200
|
+
config/deploy/staging.rb:
|
201
|
+
```xml
|
202
|
+
set :jenkins_template_vars, {
|
203
|
+
:credential_id => 'STAGING-CREDENTIAL_ID'
|
204
|
+
}
|
205
|
+
```
|
206
|
+
|
207
|
+
config/deploy/production.rb:
|
208
|
+
```xml
|
209
|
+
set :jenkins_template_vars, {
|
210
|
+
:credential_id => 'PRODUCTION-CREDENTIAL_ID'
|
211
|
+
}
|
212
|
+
```
|
213
|
+
|
118
214
|
### View Configuration
|
119
215
|
|
120
216
|
config directory structure(name your json file as a node name):
|
@@ -166,37 +262,49 @@ set :jenkins_host, 'http://localhost:8080'
|
|
166
262
|
before 'deploy', 'jenkins:config_views'
|
167
263
|
```
|
168
264
|
|
169
|
-
|
265
|
+
## Don't know how to write config.xml?
|
170
266
|
|
171
|
-
|
172
|
-
Then,
|
173
|
-
ommit `<owner class="hudson" reference="../../.."/>` line.
|
267
|
+
First, create the job, node, or view you want to manage with via the Jenkins UI.
|
268
|
+
Then, runnning following command to download them:
|
174
269
|
|
175
|
-
|
270
|
+
```
|
271
|
+
# For the job
|
272
|
+
curl -o config/jenkins/jobs/<job_name>.xml http://jenkins.example.org/job/<job_name>/config.xml
|
176
273
|
|
177
|
-
|
274
|
+
# For the node
|
275
|
+
curl -o config/jenkins/nodes/<node_name>.xml http://jenkins.example.org/computer/<node_name>/config.xml
|
178
276
|
|
179
|
-
|
180
|
-
|
277
|
+
# For the view
|
278
|
+
curl -o config/jenkins/views/<view_name>.xml http://jenkins.example.org/view/<view_name>/config.xml
|
279
|
+
```
|
181
280
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
set :scm, :git
|
186
|
-
set :repository, "https://github.com/your/repository.git"
|
281
|
+
## Known Issues
|
282
|
+
|
283
|
+
### Using mutlibyte characters in config.xml
|
187
284
|
|
188
|
-
|
189
|
-
|
190
|
-
#set :jenkins_plugins, %w(cron_column@1.1.2 envinject join@1.0.0)
|
191
|
-
set :jenkins_install_timeout, 60 * 5 # default: 5min
|
192
|
-
set :jenkins_plugin_enable_update, false # dafault: false
|
193
|
-
set :jenkins_plugin_enable_restart, false # default: false
|
285
|
+
Until [jenkins_api_client PR143](https://github.com/arangamani/jenkins_api_client/pull/143) merged,
|
286
|
+
put following code to your Gemfile:
|
194
287
|
|
195
|
-
|
288
|
+
```ruby
|
289
|
+
# FIXME after https://github.com/arangamani/jenkins_api_client/pull/143 merged
|
290
|
+
gem 'jenkins_api_client', github: 'cynipe/jenkins_api_client', branch: 'fix-multibyte-configs'
|
196
291
|
```
|
197
292
|
|
293
|
+
## TODO
|
294
|
+
|
295
|
+
* [ ] Reverse config support. something like `cap jenkins:reverse_job`
|
296
|
+
* [ ] CI cucumber tests on Wercker
|
297
|
+
* [ ] Capistrano v3 support
|
298
|
+
* [ ] Make examples triable on user's local
|
299
|
+
* [ ] Collect usage report using Google Analytics to see who uses this tool.
|
300
|
+
|
198
301
|
## Release Notes
|
199
302
|
|
303
|
+
### 0.1.0
|
304
|
+
* **[INCOMPATIBLE CHANGE]** Remove plugin support
|
305
|
+
* **[INCOMPATIBLE CHANGE]** Change node configuration to use config.xml instead of json config
|
306
|
+
* Support erb template for config.xml(need to name the file xxx.xml.erb)
|
307
|
+
|
200
308
|
### 0.0.7
|
201
309
|
* Fix disable_job is not working with recent version of Jenkins ([#9](https://github.com/cynipe/jenkins-capistrano/pull/9))
|
202
310
|
|
@@ -210,9 +318,14 @@ before 'deploy', 'jenkins:install_plugins'
|
|
210
318
|
## Contributing
|
211
319
|
|
212
320
|
1. Fork it
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
321
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
322
|
+
1. Commit your changes (`git commit -am 'Added some feature'`)
|
323
|
+
1. Run Integration tests as following:
|
324
|
+
|
325
|
+
$ vagrant up
|
326
|
+
$ bundle exec cucumber
|
327
|
+
|
328
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
329
|
+
1. Create new Pull Request
|
217
330
|
|
218
331
|
[](http://githalytics.com/cynipe/jenkins-capistrano)
|