##// END OF EJS Templates
Adds sqlserver configuration for the CI server....
Jean-Philippe Lang -
r10971:db26041f831c
parent child
Show More
@@ -1,78 +1,81
1 desc "Run the Continous Integration tests for Redmine"
1 desc "Run the Continous Integration tests for Redmine"
2 task :ci do
2 task :ci do
3 # RAILS_ENV and ENV[] can diverge so force them both to test
3 # RAILS_ENV and ENV[] can diverge so force them both to test
4 ENV['RAILS_ENV'] = 'test'
4 ENV['RAILS_ENV'] = 'test'
5 RAILS_ENV = 'test'
5 RAILS_ENV = 'test'
6 Rake::Task["ci:setup"].invoke
6 Rake::Task["ci:setup"].invoke
7 Rake::Task["ci:build"].invoke
7 Rake::Task["ci:build"].invoke
8 Rake::Task["ci:teardown"].invoke
8 Rake::Task["ci:teardown"].invoke
9 end
9 end
10
10
11 # Tasks can be hooked into by redefining them in a plugin
11 # Tasks can be hooked into by redefining them in a plugin
12 namespace :ci do
12 namespace :ci do
13 desc "Setup Redmine for a new build."
13 desc "Setup Redmine for a new build."
14 task :setup do
14 task :setup do
15 Rake::Task["ci:dump_environment"].invoke
15 Rake::Task["ci:dump_environment"].invoke
16 Rake::Task["db:create"].invoke
16 Rake::Task["db:create"].invoke
17 Rake::Task["db:migrate"].invoke
17 Rake::Task["db:migrate"].invoke
18 Rake::Task["db:schema:dump"].invoke
18 Rake::Task["db:schema:dump"].invoke
19 Rake::Task["test:scm:update"].invoke
19 Rake::Task["test:scm:update"].invoke
20 end
20 end
21
21
22 desc "Build Redmine"
22 desc "Build Redmine"
23 task :build do
23 task :build do
24 Rake::Task["test"].invoke
24 Rake::Task["test"].invoke
25 end
25 end
26
26
27 # Use this to cleanup after building or run post-build analysis.
27 # Use this to cleanup after building or run post-build analysis.
28 desc "Finish the build"
28 desc "Finish the build"
29 task :teardown do
29 task :teardown do
30 end
30 end
31
31
32 desc "Creates and configures the databases for the CI server"
32 desc "Creates and configures the databases for the CI server"
33 task :database do
33 task :database do
34 path = 'config/database.yml'
34 path = 'config/database.yml'
35 unless File.exists?(path)
35 unless File.exists?(path)
36 database = ENV['DATABASE_ADAPTER']
36 database = ENV['DATABASE_ADAPTER']
37 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
37 ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
38 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
38 branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
39 dev_db_name = "ci_#{branch}_#{ruby}_dev"
39 dev_db_name = "ci_#{branch}_#{ruby}_dev"
40 test_db_name = "ci_#{branch}_#{ruby}_test"
40 test_db_name = "ci_#{branch}_#{ruby}_test"
41
41
42 case database
42 case database
43 when 'mysql'
43 when 'mysql'
44 raise "Error creating databases" unless
44 raise "Error creating databases" unless
45 system(%|mysql -u jenkins --password=jenkins -e 'create database #{dev_db_name} character set utf8;'|) &&
45 system(%|mysql -u jenkins --password=jenkins -e 'create database #{dev_db_name} character set utf8;'|) &&
46 system(%|mysql -u jenkins --password=jenkins -e 'create database #{test_db_name} character set utf8;'|)
46 system(%|mysql -u jenkins --password=jenkins -e 'create database #{test_db_name} character set utf8;'|)
47 dev_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' }
47 dev_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' }
48 test_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' }
48 test_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' }
49 when 'postgresql'
49 when 'postgresql'
50 raise "Error creating databases" unless
50 raise "Error creating databases" unless
51 system(%|psql -U jenkins -d postgres -c "create database #{dev_db_name} owner jenkins encoding 'UTF8';"|) &&
51 system(%|psql -U jenkins -d postgres -c "create database #{dev_db_name} owner jenkins encoding 'UTF8';"|) &&
52 system(%|psql -U jenkins -d postgres -c "create database #{test_db_name} owner jenkins encoding 'UTF8';"|)
52 system(%|psql -U jenkins -d postgres -c "create database #{test_db_name} owner jenkins encoding 'UTF8';"|)
53 dev_conf = { 'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' }
53 dev_conf = { 'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' }
54 test_conf = { 'adapter' => 'postgresql', 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' }
54 test_conf = { 'adapter' => 'postgresql', 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' }
55 when 'sqlite3'
55 when 'sqlite3'
56 dev_conf = { 'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3" }
56 dev_conf = { 'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3" }
57 test_conf = { 'adapter' => 'sqlite3', 'database' => "db/#{test_db_name}.sqlite3" }
57 test_conf = { 'adapter' => 'sqlite3', 'database' => "db/#{test_db_name}.sqlite3" }
58 when 'sqlserver'
59 dev_conf = { 'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins' }
60 test_conf = { 'adapter' => 'sqlserver', 'database' => test_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins' }
58 else
61 else
59 raise "Unknown database"
62 raise "Unknown database"
60 end
63 end
61
64
62 File.open(path, 'w') do |f|
65 File.open(path, 'w') do |f|
63 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
66 f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
64 end
67 end
65 end
68 end
66 end
69 end
67
70
68 desc "Dump the environment information to a BUILD_ENVIRONMENT ENV variable for debugging"
71 desc "Dump the environment information to a BUILD_ENVIRONMENT ENV variable for debugging"
69 task :dump_environment do
72 task :dump_environment do
70
73
71 ENV['BUILD_ENVIRONMENT'] = ['ruby -v', 'gem -v', 'gem list'].collect do |command|
74 ENV['BUILD_ENVIRONMENT'] = ['ruby -v', 'gem -v', 'gem list'].collect do |command|
72 result = `#{command}`
75 result = `#{command}`
73 "$ #{command}\n#{result}"
76 "$ #{command}\n#{result}"
74 end.join("\n")
77 end.join("\n")
75
78
76 end
79 end
77 end
80 end
78
81
General Comments 0
You need to be logged in to leave comments. Login now