Skip to content

Commit

Permalink
Fix example for new configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
cynipe committed Jul 11, 2014
1 parent e0cbdad commit 6692034
Show file tree
Hide file tree
Showing 22 changed files with 287 additions and 161 deletions.
4 changes: 3 additions & 1 deletion example/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source 'https://rubygems.org'

gem 'railsless-deploy'
gem 'jenkins-capistrano'
gem 'capistrano_colors'
gem 'pry'
gem 'jenkins-capistrano', :path => '..'
30 changes: 13 additions & 17 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
# jenkins-capistrano example

jenkins-capistranoを使って、master-slave構成のJenkinsに以下のことを行う設定例
This is a example **batch** project with jekins-capistrano configs
which deploy and configure the following staff to the master-slave Jenkins:

* バッチで必要なジョブ
* バッチを実際に実行するためのスレーブノードの登録
* バッチプログラム(binディレクトリ)のデプロイ
* A job to execute the batch program
* A node to excute the job
* The batch program itself

## 前提
## Deploy

* ローカルにruby1.8.7+が入っていること
* 各スレーブノードに`/opt/hello`ディレクトリがあること
* `/opt/hello`ディレクトリにjenkinsユーザが書き込み権限があること
* jenkinsユーザがマスターノードからスレーブノードに公開鍵認証で接続できること
### Development

## デプロイの仕方

本番環境:
```
$ script/deploy production
$ script/deploy
```

ステージング環境:
### Staging

```
$ script/deploy staging
```

開発環境:
### Production

```
$ script/deploy
$ script/deploy production
```

20 changes: 8 additions & 12 deletions example/config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
set :application, 'hello'
set :repository, 'http://example.org/your/repository.git'
set :scm, :git
set :branch, 'develop' # デフォルトブランチの設定
set :deploy_via, :copy # ローカルクローンしてリモートにコピー(リモートでクローンしないように)
set :branch, 'develop'
set :deploy_via, :copy
set :deploy_to, "/opt/#{application}"
set :use_sudo, false
set :keep_releases, 5

set :stages, %w(develop staging production)
set :default_stage, 'develop'

set :user, 'jenkins'
# 公開鍵認証を推奨
#set :password do
# ENV['DEPLOY_PASSWORD'] || Capistrano::CLI.password_prompt("linux user password[#{user}]: ")
#end
set :user, 'vagrant'
set :password do
ENV['DEPLOY_PASSWORD'] || Capistrano::CLI.password_prompt("linux user password[#{user}]: ")
end

set :jenkins_username, user
# 必要であれば
# if you need the credentials
# set :jenkins_username, 'jenkins'
#set :jenkins_password do
# ENV['DEPLOY_PASSWORD'] || Capistrano::CLI.password_prompt("jenkins server password[#{user}]: ")
#end
Expand All @@ -27,9 +26,6 @@
after 'deploy', 'jenkins:deploy_jobs'
after 'deploy', 'deploy:cleanup'

# ローカルにgitコマンドがあること
depend :local, :command, 'git'
# リモートにデプロイ用ディレクトリがあること
depend :remote, :directory, deploy_to
# jenkinsユーザで書き込みができること
depend :remote, :writable, deploy_to
8 changes: 5 additions & 3 deletions example/config/deploy/develop.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ブランチはconfig/deploy.rbの設定に従う
role :batch, 'dev-slave01.local'
set :jenkins_host, 'dev-master.local'
role :batch, 'localhsot:22222'
set :jenkins_host, 'localhost:8080'
set :jenkins_node_config_dir, 'config/jenkins/nodes/develop'

set :jenkins_template_vars, {
credential_id: 'AAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'
}
16 changes: 13 additions & 3 deletions example/config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
set :branch, 'v1.0.0'

role :batch, 'prod-slave01.local'
# 複数ノードの場合
#role :batch, 'prod-slave02.local'
#role :batch, 'prod-slave03.local'
role :batch, 'prod-slave02.local'
role :batch, 'prod-slave03.local'

set :jenkins_host, 'prod-master.local'
set :jenkins_node_config_dir, 'config/jenkins/nodes/production'
set :jenkins_template_vars, {
slave01: {
credential_id: 'PRODUCTION-SLAVE01-CREDENTIAL',
},
slave02: {
credential_id: 'PRODUCTION-SLAVE02-CREDENTIAL',
},
slave03: {
credential_id: 'PRODUCTION-SLAVE03-CREDENTIAL',
}
}
17 changes: 13 additions & 4 deletions example/config/deploy/staging.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
set :branch, 'release/1.0.1'

role :batch, 'stg-slave01.local'
# 複数ノードの場合
#role :batch, 'stg-slave02.local'
#role :batch, 'stg-slave03.local'
role :batch, 'stg-slave02.local'
role :batch, 'stg-slave03.local'

set :jenkins_host, 'stg-master.local'
set :jenkins_node_config_dir, 'config/jenkins/nodes/staging'

set :jenkins_template_vars, {
slave01: {
credential_id: 'STAGING-SLAVE01-CREDENTIAL',
},
slave02: {
credential_id: 'STAGING-SLAVE02-CREDENTIAL',
},
slave03: {
credential_id: 'STAGING-SLAVE03-CREDENTIAL',
}
}
Empty file.
17 changes: 0 additions & 17 deletions example/config/jenkins/nodes/develop/dev-slave01.json

This file was deleted.

33 changes: 33 additions & 0 deletions example/config/jenkins/nodes/develop/dev-slave01.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>dev-slave01</name>
<description>Slave01</description>
<remoteFS>/home/jenkins</remoteFS>
<numExecutors>5</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]">
<host>dev-slave01.local</host>
<port>22</port>
<credentialsId><%= @credential_id %></credentialsId>
<jvmOptions>-Dfile.encoding=UTF-8</jvmOptions>
</launcher>
<label>hello</label>
<nodeProperties>
<hudson.slaves.EnvironmentVariablesNodeProperty>
<envVars serialization="custom">
<unserializable-parents/>
<tree-map>
<default>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
</default>
<int>2</int><!-- must specify env var count -->
<string>LANG</string>
<string>ja_JP.UTF-8</string>
<string>ENVIRONMENT</string>
<string>develop</string>
</tree-map>
</envVars>
</hudson.slaves.EnvironmentVariablesNodeProperty>
</nodeProperties>
</slave>
17 changes: 0 additions & 17 deletions example/config/jenkins/nodes/production/prod-slave01.json

This file was deleted.

33 changes: 33 additions & 0 deletions example/config/jenkins/nodes/production/prod-slave01.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>prod-slave01</name>
<description>Slave01</description>
<remoteFS>/home/jenkins</remoteFS>
<numExecutors>5</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]">
<host>prod-slave01.local</host>
<port>22</port>
<credentialsId><%= @slave01[:credential_id] %></credentialsId>
<jvmOptions>-Dfile.encoding=UTF-8</jvmOptions>
</launcher>
<label>hello</label>
<nodeProperties>
<hudson.slaves.EnvironmentVariablesNodeProperty>
<envVars serialization="custom">
<unserializable-parents/>
<tree-map>
<default>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
</default>
<int>2</int><!-- must specify env var count -->
<string>LANG</string>
<string>ja_JP.UTF-8</string>
<string>ENVIRONMENT</string>
<string>production</string>
</tree-map>
</envVars>
</hudson.slaves.EnvironmentVariablesNodeProperty>
</nodeProperties>
</slave>
17 changes: 0 additions & 17 deletions example/config/jenkins/nodes/production/prod-slave02.json

This file was deleted.

33 changes: 33 additions & 0 deletions example/config/jenkins/nodes/production/prod-slave02.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>prod-slave02</name>
<description>Slave02</description>
<remoteFS>/home/jenkins</remoteFS>
<numExecutors>5</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]">
<host>prod-slave02.local</host>
<port>22</port>
<credentialsId><%= @slave02[:credential_id] %></credentialsId>
<jvmOptions>-Dfile.encoding=UTF-8</jvmOptions>
</launcher>
<label>hello</label>
<nodeProperties>
<hudson.slaves.EnvironmentVariablesNodeProperty>
<envVars serialization="custom">
<unserializable-parents/>
<tree-map>
<default>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
</default>
<int>2</int><!-- must specify env var count -->
<string>LANG</string>
<string>ja_JP.UTF-8</string>
<string>ENVIRONMENT</string>
<string>production</string>
</tree-map>
</envVars>
</hudson.slaves.EnvironmentVariablesNodeProperty>
</nodeProperties>
</slave>
17 changes: 0 additions & 17 deletions example/config/jenkins/nodes/production/prod-slave03.json

This file was deleted.

33 changes: 33 additions & 0 deletions example/config/jenkins/nodes/production/prod-slave03.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<slave>
<name>prod-slave03</name>
<description>Slave03</description>
<remoteFS>/home/jenkins</remoteFS>
<numExecutors>5</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]">
<host>prod-slave03.local</host>
<port>22</port>
<credentialsId><%= @slave03[:credential_id] %></credentialsId>
<jvmOptions>-Dfile.encoding=UTF-8</jvmOptions>
</launcher>
<label>hello</label>
<nodeProperties>
<hudson.slaves.EnvironmentVariablesNodeProperty>
<envVars serialization="custom">
<unserializable-parents/>
<tree-map>
<default>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
</default>
<int>2</int><!-- must specify env var count -->
<string>LANG</string>
<string>ja_JP.UTF-8</string>
<string>ENVIRONMENT</string>
<string>production</string>
</tree-map>
</envVars>
</hudson.slaves.EnvironmentVariablesNodeProperty>
</nodeProperties>
</slave>
17 changes: 0 additions & 17 deletions example/config/jenkins/nodes/staging/stg-slave01.json

This file was deleted.

Loading

0 comments on commit 6692034

Please sign in to comment.