Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 1d1ae99

Browse files
committed
Merge pull request #116 from SuperTux88/bitbucket
Add Bitbucket Server 4.0 Support
2 parents 39ea123 + dd8ea24 commit 1d1ae99

23 files changed

+5332
-70
lines changed

.kitchen.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ driver_config:
1010
memory: 1024
1111

1212
platforms:
13-
- name: centos-6
13+
- name: centos-6.7
1414
driver_config:
15-
box: chef/centos-6.6
15+
box: chef/centos-6.7
1616
run_list:
1717
- recipe[yum]
18-
- name: centos-7
18+
- name: centos-7.1
1919
driver_config:
20-
box: chef/centos-7.0
20+
box: chef/centos-7.1
2121
run_list:
2222
- recipe[yum]
2323
- name: ubuntu-12.04
@@ -34,8 +34,8 @@ platforms:
3434
default_attributes: &DEFAULT_ATTRIBUTES
3535
java:
3636
install_flavor: oracle
37-
java_home: /usr/lib/jvm/java-7-oracle
38-
jdk_version: 7
37+
java_home: /usr/lib/jvm/java-8-oracle
38+
jdk_version: 8
3939
oracle:
4040
accept_oracle_download_terms: true
4141

Vagrantfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Vagrant.configure('2') do |config|
77
config.omnibus.chef_version = :latest
88

99
config.vm.define :centos6 do |centos6|
10-
centos6.vm.box = 'chef/centos-6.6'
10+
centos6.vm.box = 'chef/centos-6.7'
1111
centos6.vm.hostname = "#{cookbook}-centos-6"
1212
end
1313

1414
config.vm.define :centos7 do |centos7|
15-
centos7.vm.box = 'chef/centos-7.0'
15+
centos7.vm.box = 'chef/centos-7.1'
1616
centos7.vm.hostname = "#{cookbook}-centos-7"
1717
end
1818

@@ -67,8 +67,8 @@ Vagrant.configure('2') do |config|
6767
chef.json = {
6868
'java' => {
6969
'install_flavor' => 'oracle',
70-
'java_home' => '/usr/lib/jvm/java-7-oracle',
71-
'jdk_version' => '7',
70+
'java_home' => '/usr/lib/jvm/java-8-oracle',
71+
'jdk_version' => '8',
7272
'oracle' => {
7373
'accept_oracle_download_terms' => true
7474
}

attributes/default.rb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
set['build_essential']['compiletime'] = true
1+
set['build-essential']['compile_time'] = true
22

3-
default['stash']['home_path'] = '/var/atlassian/application-data/stash'
3+
default['stash']['version'] = '4.0.1'
4+
default['stash']['product'] = Chef::Version.new(node['stash']['version']) >= Chef::Version.new('4.0.0') ? 'bitbucket' : 'stash'
5+
6+
default['stash']['home_path'] = "/var/atlassian/application-data/#{node['stash']['product']}"
47
default['stash']['install_path'] = '/opt/atlassian'
58
default['stash']['install_type'] = 'standalone'
69
default['stash']['service_type'] = 'init'
7-
default['stash']['url_base'] = 'http://www.atlassian.com/software/stash/downloads/binary/atlassian-stash'
8-
default['stash']['user'] = 'stash'
9-
default['stash']['version'] = '3.11.1'
10+
default['stash']['url_base'] = "http://www.atlassian.com/software/stash/downloads/binary/atlassian-#{node['stash']['product']}"
11+
default['stash']['user'] = node['stash']['product']
1012

1113
default['stash']['url'] = "#{node['stash']['url_base']}-#{node['stash']['version']}.tar.gz"
1214
default['stash']['checksum'] =
@@ -114,6 +116,7 @@
114116
when '3.10.0' then 'ab7fecb10e6650fb5b94a20b22463771d7ab0f69a0971272d1a066dd2430f048'
115117
when '3.10.2' then '2597e9954397af5016c30c9f90befd09c6da71c4e7745813c77e60329427989e'
116118
when '3.11.1' then '7db6327554e3481a8b351188991f5858d01aeebce3f9bc290da5ad9d0fbfe1e7'
119+
when '4.0.1' then 'f59462077fa4ccc522b7bbf1ad6ebef4753cd0e41abf54bc0491d07eea40593d'
117120
end
118121

119122
default['stash']['apache2']['access_log'] = ''
@@ -151,23 +154,25 @@
151154
default['stash']['backup']['cron']['weekday'] = '*'
152155

153156
default['stash']['backup_client']['install_path'] = node['stash']['install_path']
154-
default['stash']['backup_client']['password'] = 'changeit'
155-
default['stash']['backup_client']['user'] = 'admin'
156-
default['stash']['backup_client']['version'] = '1.9.1'
157+
default['stash']['backup_client']['version'] = '2.0.0'
157158
stash_backup_client_version = Chef::Version.new(node['stash']['backup_client']['version'])
158159

159160
default['stash']['backup_client']['url_base'] =
160161
if stash_backup_client_version <= Chef::Version.new('1.2.1')
161162
'http://downloads.atlassian.com/software/stash/downloads/stash-backup-client'
162-
else
163+
elsif stash_backup_client_version < Chef::Version.new('2.0.0')
163164
'https://maven.atlassian.com/public/com/atlassian/stash/backup/stash-backup-distribution/'
165+
else
166+
'https://maven.atlassian.com/repository/public/com/atlassian/bitbucket/server/backup/bitbucket-backup-distribution/'
164167
end
165168

166169
default['stash']['backup_client']['url'] =
167170
if stash_backup_client_version <= Chef::Version.new('1.2.1')
168171
"#{node['stash']['backup_client']['url_base']}-#{node['stash']['backup_client']['version']}.zip"
169-
else
172+
elsif stash_backup_client_version < Chef::Version.new('2.0.0')
170173
"#{node['stash']['backup_client']['url_base']}/#{node['stash']['backup_client']['version']}/stash-backup-distribution-#{node['stash']['backup_client']['version']}.zip"
174+
else
175+
"#{node['stash']['backup_client']['url_base']}/#{node['stash']['backup_client']['version']}/bitbucket-backup-distribution-#{node['stash']['backup_client']['version']}.zip"
171176
end
172177

173178
default['stash']['backup_client']['checksum'] =
@@ -188,6 +193,7 @@
188193
when '1.8.2' then 'ff41c353f73fe90cb0e67860cff7b021833e23df6c49232d1b102a0eae575127'
189194
when '1.9.0' then '620776f107a9c10f57f59e52be795621f0f0b8277805e28fff7dc664bbb48fb3'
190195
when '1.9.1' then '3cdad3393611d2c8d151c7d265ebd04764cbaba4a4d745a8b534dd9b8cf77d7b'
196+
when '2.0.0' then '2d9113ef6e173a65587b373ecc247b58ea8fab5ea826541b1d309ad0402a67be'
191197
end
192198

193199
default['stash']['backup_diy']['install_path'] = "#{node['stash']['install_path']}/stash-diy-backup"
@@ -211,10 +217,10 @@
211217
default['stash']['database']['version'] = nil
212218

213219
default['stash']['database']['host'] = '127.0.0.1'
214-
default['stash']['database']['name'] = 'stash'
220+
default['stash']['database']['name'] = node['stash']['product']
215221
default['stash']['database']['password'] = 'changeit'
216222
default['stash']['database']['testInterval'] = 2
217-
default['stash']['database']['user'] = 'stash'
223+
default['stash']['database']['user'] = node['stash']['product']
218224

219225
# See `libraries/stash.rb` for code to set actual default port
220226
default['stash']['database']['port'] = nil

libraries/stash.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ def self.default_database_port(type)
4747

4848
def self.check_for_old_attributes!(node)
4949
backup_attrs = %w(backup_path baseurl password user cron)
50+
show_warn = false
5051
backup_attrs.each do |attr|
51-
unless node['stash']['backup_client'][attr].nil?
52-
node.default['stash']['backup_client'][attr] = node['stash']['backup'][attr]
53-
Chef::Log.warn "node['stash']['backup_client']['#{attr}'] has been changed to node['stash']['backup']['#{attr}']"
54-
end
52+
next if node['stash']['backup_client'][attr].nil?
53+
54+
node.default['stash']['backup'][attr] = node['stash']['backup_client'][attr]
55+
Chef::Log.warn "node['stash']['backup_client']['#{attr}'] has been changed to node['stash']['backup']['#{attr}']"
56+
show_warn = true
5557
end
56-
Chef::Log.warn <<-EOH
58+
Chef::Log.warn <<-EOH if show_warn
5759
This renaming introduces the common approach for both of backup strategies:
58-
'backup_client' and 'backup_diy'. Attributes metioned above will be gracefully
60+
'backup_client' and 'backup_diy'. Attributes mentioned above will be gracefully
5961
converted for you, but this warning and conversion will be removed in the next
6062
major release of the 'stash' cookbook.
6163
EOH

recipes/backup_client.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
package 'unzip'
66
package 'rsync'
77

8-
ark 'stash-backup-client' do
8+
backup_client_install_path = "#{node['stash']['backup_client']['install_path']}/#{node['stash']['product']}-backup-client"
9+
10+
ark "#{node['stash']['product']}-backup-client" do
911
url node['stash']['backup_client']['url']
1012
prefix_root node['stash']['backup_client']['install_path']
1113
prefix_home node['stash']['backup_client']['install_path']
@@ -22,7 +24,7 @@
2224
variables :backup => settings['backup']
2325
end
2426

25-
link "#{node['stash']['backup_client']['install_path']}/stash-backup-client/backup-config.properties" do
27+
link "#{backup_client_install_path}/backup-config.properties" do
2628
to "#{node['stash']['home_path']}/backup-config.properties"
2729
end
2830

@@ -33,13 +35,13 @@
3335
not_if { ::Dir.exist?(node['stash']['backup']['backup_path']) }
3436
end
3537

36-
cron_d 'atlassian-stash-backup-client' do
38+
cron_d "atlassian-#{node['stash']['product']}-backup-client" do
3739
hour settings['backup']['cron']['hour']
3840
minute settings['backup']['cron']['minute']
3941
day settings['backup']['cron']['day']
4042
month settings['backup']['cron']['month']
4143
weekday settings['backup']['cron']['weekday']
42-
command "java -jar #{node['stash']['backup_client']['install_path']}/stash-backup-client/stash-backup-client.jar"
44+
command "java -jar #{backup_client_install_path}/#{node['stash']['product']}-backup-client.jar"
4345
user node['stash']['user']
4446
action(settings['backup']['cron']['enable'] ? :create : :delete)
4547
end

recipes/configuration.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@
44
# Config path changed to shared/ from 3.2.0
55
# https://confluence.atlassian.com/display/STASHKB/Upgrading+your+Stash+home+directory+for+Stash+3.2+manually
66
if stash_version >= Chef::Version.new('3.2.0')
7-
config_path = 'shared/'
8-
directory("#{node['stash']['home_path']}/#{config_path}") do
7+
if node['stash']['product'] == 'stash'
8+
config_path = 'shared/stash-config.properties'
9+
else
10+
config_path = 'shared/bitbucket.properties'
11+
12+
# delete old config file from stash, when both configs exist, bitbucket will not start
13+
file "#{node['stash']['home_path']}/shared/stash-config.properties" do
14+
action :delete
15+
end
16+
end
17+
18+
directory("#{node['stash']['home_path']}/shared") do
919
owner node['stash']['user']
1020
group node['stash']['user']
1121
mode '0755'
1222
action :create
1323
recursive true
1424
end
1525
else
16-
config_path = '/'
26+
config_path = '/stash-config.properties'
1727
end
1828

19-
template "#{node['stash']['home_path']}/#{config_path}stash-config.properties" do
29+
template "#{node['stash']['home_path']}/#{config_path}" do
2030
source 'stash-config.properties.erb'
2131
owner node['stash']['user']
2232
mode '0644'
@@ -26,5 +36,5 @@
2636
:plugin => settings['plugin'],
2737
:properties => settings['properties']
2838
)
29-
notifies :restart, 'service[stash]', :delayed
39+
notifies :restart, "service[#{node['stash']['product']}]", :delayed
3040
end

recipes/linux_standalone.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
recursive true
4141
end
4242

43-
ark 'stash' do
43+
ark node['stash']['product'] do
4444
url node['stash']['url']
4545
prefix_root node['stash']['install_path']
4646
prefix_home node['stash']['install_path']

recipes/service_init.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
template '/etc/init.d/stash' do
2-
source 'stash.init.erb'
1+
template "/etc/init.d/#{node['stash']['product']}" do
2+
if node['stash']['product'] == 'stash'
3+
source 'stash.init.erb'
4+
else
5+
source 'bitbucket/bitbucket.init.erb'
6+
end
37
mode '0755'
4-
notifies :restart, 'service[stash]', :delayed
8+
notifies :restart, "service[#{node['stash']['product']}]", :delayed
59
end
610

7-
service 'stash' do
11+
# disable stash service after upgrade to bitbucket 4.0
12+
if node['stash']['product'] == 'bitbucket'
13+
service 'stash' do
14+
supports :status => true, :restart => true
15+
action [:stop, :disable]
16+
end
17+
18+
file '/etc/init.d/stash' do
19+
action :delete
20+
end
21+
end
22+
23+
service node['stash']['product'] do
824
supports :status => true, :restart => true
925
action [:enable]
1026
subscribes :restart, 'java_ark[jdk]'

recipes/tomcat_configuration.rb

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
server_xml_path = "#{node['stash']['home_path']}/shared/server.xml"
77
end
88

9-
template "#{node['stash']['install_path']}/stash/bin/setenv.sh" do
9+
template "#{node['stash']['install_path']}/#{node['stash']['product']}/bin/setenv.sh" do
1010
if stash_version < Chef::Version.new('3.8.0')
1111
source 'setenv.sh.erb'
12-
else
12+
elsif node['stash']['product'] == 'stash'
1313
source '3.8+/setenv.sh.erb'
14+
else
15+
source 'bitbucket/setenv.sh.erb'
1416
end
1517
owner node['stash']['user']
1618
mode '0755'
17-
notifies :restart, 'service[stash]', :delayed
19+
notifies :restart, "service[#{node['stash']['product']}]", :delayed
1820
end
1921

2022
template server_xml_path do
@@ -24,31 +26,43 @@
2426
source 'server-tomcat7.xml.erb'
2527
elsif stash_version < Chef::Version.new('3.8.0')
2628
source 'server-tomcat8.xml.erb'
27-
else
29+
elsif node['stash']['product'] == 'stash'
2830
source '3.8+/server.xml.erb'
31+
else
32+
source 'bitbucket/server.xml.erb'
2933
end
3034
owner node['stash']['user']
3135
mode '0640'
3236
variables :tomcat => settings['tomcat']
33-
notifies :restart, 'service[stash]', :delayed
37+
notifies :restart, "service[#{node['stash']['product']}]", :delayed
3438
end
3539

36-
template "#{node['stash']['install_path']}/stash/conf/web.xml" do
40+
template "#{node['stash']['install_path']}/#{node['stash']['product']}/conf/web.xml" do
3741
if stash_version.major == 1
3842
source 'web.xml.erb'
3943
elsif stash_version < Chef::Version.new('3.8.0')
4044
source 'web-tomcat7.xml.erb'
41-
else
45+
elsif node['stash']['product'] == 'stash'
4246
source '3.8+/web.xml'
47+
else
48+
source 'bitbucket/web.xml'
4349
end
4450
owner node['stash']['user']
4551
mode '0644'
46-
notifies :restart, 'service[stash]', :delayed
52+
notifies :restart, "service[#{node['stash']['product']}]", :delayed
4753
end
4854

49-
directory '/var/run/stash' do
50-
owner 'stash'
51-
group 'stash'
55+
directory "/var/run/#{node['stash']['product']}" do
56+
owner node['stash']['user']
57+
group node['stash']['user']
5258
mode '0755'
5359
action :create
5460
end
61+
62+
template "#{node['stash']['install_path']}/bitbucket/bin/user.sh" do
63+
source 'bitbucket/user.sh.erb'
64+
owner node['stash']['user']
65+
mode '0755'
66+
notifies :restart, "service[#{node['stash']['product']}]", :delayed
67+
only_if { node['stash']['product'] == 'bitbucket' }
68+
end

0 commit comments

Comments
 (0)