Commit 2e5cf8130a2ad5b4734343c296e013ec5407b3a2
Exists in
master
and in
89 other branches
Merge branch 'ci' into 'master'
Receita de implantação do Jenkins See merge request !28
Showing
3 changed files
with
82 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +upstream app_server { | |
| 2 | + server 127.0.0.1:8080 fail_timeout=0; | |
| 3 | +} | |
| 4 | + | |
| 5 | +server { | |
| 6 | + listen 80; | |
| 7 | + listen [::]:80 default ipv6only=on; | |
| 8 | + server_name ci.spb.lappis; | |
| 9 | + | |
| 10 | + location / { | |
| 11 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| 12 | + proxy_set_header Host $http_host; | |
| 13 | + proxy_redirect off; | |
| 14 | + | |
| 15 | + if (!-f $request_filename) { | |
| 16 | + proxy_pass http://app_server; | |
| 17 | + break; | |
| 18 | + } | |
| 19 | + } | |
| 20 | +} | |
| 0 | 21 | \ No newline at end of file | ... | ... |
cookbooks/ci/recipes/default.rb
| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | +JENKINS_CLI = '/var/cache/jenkins/war/WEB-INF/jenkins-cli.jar' | |
| 2 | + | |
| 3 | +execute 'jenkins_repo' do | |
| 4 | + command 'wget -q -O - http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key | sudo apt-key add -' | |
| 5 | +end | |
| 6 | + | |
| 7 | +execute 'apt_sources' do | |
| 8 | + command 'echo "deb http://pkg.jenkins-ci.org/debian-stable binary/" >> /etc/apt/sources.list' | |
| 9 | + not_if 'cat /etc/apt/sources.list | grep jenkins-ci' | |
| 10 | +end | |
| 11 | + | |
| 12 | +execute 'apt-get update' | |
| 13 | + | |
| 14 | +package 'jenkins' | |
| 15 | + | |
| 16 | +service 'jenkins' do | |
| 17 | + action :enable | |
| 18 | +end | |
| 19 | + | |
| 20 | +execute 'service jenkins restart' | |
| 21 | + | |
| 22 | +package 'nginx' | |
| 23 | + | |
| 24 | +service 'nginx' do | |
| 25 | + action [:enable, :start] | |
| 26 | +end | |
| 27 | + | |
| 28 | +file '/etc/nginx/sites-available/default' do | |
| 29 | + action :delete | |
| 30 | +end | |
| 31 | + | |
| 32 | +cookbook_file 'nginx' do | |
| 33 | + path '/etc/nginx/sites-available/jenkins' | |
| 34 | +end | |
| 35 | + | |
| 36 | +file '/etc/nginx/sites-enabled/default' do | |
| 37 | + action :delete | |
| 38 | +end | |
| 39 | + | |
| 40 | +link '/etc/nginx/sites-enabled/jenkins' do | |
| 41 | + to '/etc/nginx/sites-available/jenkins' | |
| 42 | + not_if 'test -L /etc/nginx/sites-enabled/jenkins' | |
| 43 | +end | |
| 44 | + | |
| 45 | +service 'nginx' do | |
| 46 | + action :restart | |
| 47 | +end | |
| 48 | + | |
| 49 | +package 'git' | |
| 50 | + | |
| 51 | +plugins = ['git-client', 'git-server', 'build-blocker-plugin', 'greenballs', 'view-job-filters', 'gitlab-plugin'] | |
| 52 | + | |
| 53 | +plugins.each do |plugin| | |
| 54 | + execute "install jenkins plugin #{plugin}" do | |
| 55 | + command "java -jar #{JENKINS_CLI} -s http://localhost/ install-plugin #{plugin}" | |
| 56 | + retries 5 | |
| 57 | + retry_delay 10 | |
| 58 | + end | |
| 59 | +end | |
| 60 | + | |
| 61 | +execute 'service jenkins restart' | |
| 0 | 62 | \ No newline at end of file | ... | ... |