rubyjobbuilderdsl 0.0.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.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +33 -0
- data/LICENSE +19 -0
- data/Rakefile +12 -0
- data/docs/common.md +313 -0
- data/docs/flow.md +18 -0
- data/docs/freestyle.md +100 -0
- data/docs/gerrit.md +70 -0
- data/docs/git.md +88 -0
- data/docs/index.md +11 -0
- data/docs/multi.md +27 -0
- data/docs/overview.md +74 -0
- data/docs/postbuild.md +266 -0
- data/docs/view.md +13 -0
- data/lib/rubyjobbuilderdsl/builder.rb +69 -0
- data/lib/rubyjobbuilderdsl/buildstep/ant.rb +29 -0
- data/lib/rubyjobbuilderdsl/buildstep/copyartifact.rb +23 -0
- data/lib/rubyjobbuilderdsl/buildstep/inject_env.rb +18 -0
- data/lib/rubyjobbuilderdsl/buildstep/phase.rb +19 -0
- data/lib/rubyjobbuilderdsl/buildstep/phase_job.rb +26 -0
- data/lib/rubyjobbuilderdsl/buildstep/shell.rb +24 -0
- data/lib/rubyjobbuilderdsl/common/artifactory.rb +33 -0
- data/lib/rubyjobbuilderdsl/common/blocking_job.rb +11 -0
- data/lib/rubyjobbuilderdsl/common/build_timeout.rb +23 -0
- data/lib/rubyjobbuilderdsl/common/gerrit.rb +53 -0
- data/lib/rubyjobbuilderdsl/common/git.rb +76 -0
- data/lib/rubyjobbuilderdsl/common/logrotate.rb +24 -0
- data/lib/rubyjobbuilderdsl/common/parameter.rb +22 -0
- data/lib/rubyjobbuilderdsl/common/password.rb +12 -0
- data/lib/rubyjobbuilderdsl/common/pollscm.rb +10 -0
- data/lib/rubyjobbuilderdsl/common/scms.rb +18 -0
- data/lib/rubyjobbuilderdsl/common/throttle.rb +24 -0
- data/lib/rubyjobbuilderdsl/common/timed.rb +10 -0
- data/lib/rubyjobbuilderdsl/common/timestamps.rb +6 -0
- data/lib/rubyjobbuilderdsl/common.rb +140 -0
- data/lib/rubyjobbuilderdsl/deployer.rb +95 -0
- data/lib/rubyjobbuilderdsl/flow.rb +14 -0
- data/lib/rubyjobbuilderdsl/freestyle.rb +57 -0
- data/lib/rubyjobbuilderdsl/jenkins_client.rb +203 -0
- data/lib/rubyjobbuilderdsl/multijob.rb +24 -0
- data/lib/rubyjobbuilderdsl/postbuild/archive.rb +23 -0
- data/lib/rubyjobbuilderdsl/postbuild/chucknorris_publisher.rb +6 -0
- data/lib/rubyjobbuilderdsl/postbuild/claim_publisher.rb +6 -0
- data/lib/rubyjobbuilderdsl/postbuild/cloverphp_publisher.rb +36 -0
- data/lib/rubyjobbuilderdsl/postbuild/email_publisher.rb +23 -0
- data/lib/rubyjobbuilderdsl/postbuild/game_publisher.rb +6 -0
- data/lib/rubyjobbuilderdsl/postbuild/groovy.rb +10 -0
- data/lib/rubyjobbuilderdsl/postbuild/html_publisher.rb +27 -0
- data/lib/rubyjobbuilderdsl/postbuild/javadoc_publisher.rb +19 -0
- data/lib/rubyjobbuilderdsl/postbuild/logparser.rb +21 -0
- data/lib/rubyjobbuilderdsl/postbuild/nunit_publisher.rb +21 -0
- data/lib/rubyjobbuilderdsl/postbuild/pmd_publisher.rb +19 -0
- data/lib/rubyjobbuilderdsl/postbuild/script.rb +14 -0
- data/lib/rubyjobbuilderdsl/postbuild/tap_publisher.rb +44 -0
- data/lib/rubyjobbuilderdsl/postbuild/trigger.rb +38 -0
- data/lib/rubyjobbuilderdsl/postbuild/xunit_publisher.rb +35 -0
- data/lib/rubyjobbuilderdsl/postbuild.rb +146 -0
- data/lib/rubyjobbuilderdsl/view.rb +14 -0
- data/lib/rubyjobbuilderdsl/xml_generator.rb +839 -0
- data/lib/rubyjobbuilderdsl.rb +2 -0
- data/rubyjobbuilderdsl.gemspec +13 -0
- data/rubyjobbuilderdsl.sublime-project +14 -0
- data/run_tests.sh +7 -0
- data/sample/hello_mars.rb +27 -0
- data/sample/local.ini +4 -0
- data/test/test_ant.rb +38 -0
- data/test/test_archive.rb +24 -0
- data/test/test_artifactory.rb +26 -0
- data/test/test_blocking_job.rb +18 -0
- data/test/test_chucknorris_publisher.rb +17 -0
- data/test/test_claim_publisher.rb +17 -0
- data/test/test_cloverphp.rb +33 -0
- data/test/test_concurrent.rb +44 -0
- data/test/test_copyartifact.rb +45 -0
- data/test/test_default_setting.rb +29 -0
- data/test/test_email_publisher.rb +44 -0
- data/test/test_flow.rb +19 -0
- data/test/test_freestyle.rb +52 -0
- data/test/test_game_publisher.rb +17 -0
- data/test/test_gerrit.rb +117 -0
- data/test/test_git.rb +80 -0
- data/test/test_html_publisher.rb +57 -0
- data/test/test_inject.rb +23 -0
- data/test/test_javadoc.rb +22 -0
- data/test/test_logparser.rb +24 -0
- data/test/test_logrotate.rb +22 -0
- data/test/test_multijob.rb +50 -0
- data/test/test_nunit_publisher.rb +20 -0
- data/test/test_parameter.rb +44 -0
- data/test/test_password.rb +17 -0
- data/test/test_pmd.rb +22 -0
- data/test/test_pollscm.rb +15 -0
- data/test/test_postbuild_groovy.rb +21 -0
- data/test/test_postbuild_script.rb +24 -0
- data/test/test_postbuild_trigger.rb +170 -0
- data/test/test_scms.rb +31 -0
- data/test/test_tap_publisher.rb +25 -0
- data/test/test_timed.rb +15 -0
- data/test/test_timeout.rb +20 -0
- data/test/test_timestamps.rb +14 -0
- data/test/test_xml_generator.rb +28 -0
- data/test/test_xunit_publisher.rb +22 -0
- metadata +173 -0
data/test/test_git.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlGit < Test::Unit::TestCase
|
|
4
|
+
def test_git
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
git do
|
|
9
|
+
url 'ssh://bar@gerrit.mycompany.com:29418/foo'
|
|
10
|
+
basedir 'foo'
|
|
11
|
+
reference_repo '$HOME/foo.git'
|
|
12
|
+
branches '$GERRIT_BRANCH'
|
|
13
|
+
refspec '$GERRIT_REFSPEC'
|
|
14
|
+
choosing_strategy 'gerrit'
|
|
15
|
+
git_config_name 'bar'
|
|
16
|
+
git_config_email 'bar@mycompany.com'
|
|
17
|
+
clean true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
actual = builder.config_as_xml_node('foo')
|
|
22
|
+
|
|
23
|
+
assert_equal '2', actual.xpath("./project/scm[contains(@class,'hudson.plugins.git.GitSCM') and @plugin='git@2.0']/configVersion").text
|
|
24
|
+
|
|
25
|
+
{ 'name' => 'origin', 'refspec' => '$GERRIT_REFSPEC',
|
|
26
|
+
'url' => 'ssh://bar@gerrit.mycompany.com:29418/foo' }.each do |k, v|
|
|
27
|
+
assert_equal v, actual.xpath("./project/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/#{k}").text, k
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
assert_equal '$GERRIT_BRANCH', actual.xpath('./project/scm/branches/hudson.plugins.git.BranchSpec/name').text
|
|
31
|
+
|
|
32
|
+
assert actual.at('./project/scm/extensions/hudson.plugins.git.extensions.impl.BuildChooserSetting/' \
|
|
33
|
+
"buildChooser[contains(@class,'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser')]")
|
|
34
|
+
|
|
35
|
+
assert_equal 'foo', actual.xpath('./project/scm/extensions/' \
|
|
36
|
+
'hudson.plugins.git.extensions.impl.RelativeTargetDirectory/relativeTargetDir').text
|
|
37
|
+
assert_equal '$HOME/foo.git', actual.xpath('./project/scm/extensions/' \
|
|
38
|
+
'hudson.plugins.git.extensions.impl.CloneOption/reference').text
|
|
39
|
+
|
|
40
|
+
{ 'name' => 'bar', 'email' => 'bar@mycompany.com' }.each do |k, v|
|
|
41
|
+
assert_equal v, actual.xpath("./project/scm/extensions/hudson.plugins.git.extensions.impl.UserIdentity/#{k}").text, k
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
assert actual.at('./project/scm/extensions/hudson.plugins.git.extensions.impl.CleanCheckout')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_filter_by_path
|
|
48
|
+
builder = JenkinsJob::Builder.new
|
|
49
|
+
|
|
50
|
+
builder.freestyle 'foo' do
|
|
51
|
+
git do
|
|
52
|
+
url 'ssh://bar@gerrit.mycompany.com:29418/foo/a'
|
|
53
|
+
file 'src/a/.*',
|
|
54
|
+
'src/Db/a/.*'
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
actual = builder.config_as_xml_node('foo')
|
|
59
|
+
|
|
60
|
+
assert_equal "src/a/.*\nsrc/Db/a/.*", actual.xpath('./project/scm/extensions/' \
|
|
61
|
+
'hudson.plugins.git.extensions.impl.PathRestriction/includedRegions').text
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_jgit
|
|
65
|
+
builder = JenkinsJob::Builder.new
|
|
66
|
+
|
|
67
|
+
builder.freestyle 'foo' do
|
|
68
|
+
git do
|
|
69
|
+
url 'bar@git.mycompany.com:/foo'
|
|
70
|
+
jgit
|
|
71
|
+
credentials 'bar'
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
actual = builder.config_as_xml_node('foo')
|
|
76
|
+
|
|
77
|
+
assert_equal 'jgit', actual.xpath('./project/scm/gitTool').text
|
|
78
|
+
assert_equal 'bar', actual.xpath('./project/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/credentialsId').text
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlHtmlPublisher < Test::Unit::TestCase
|
|
4
|
+
def test_postbuild_html_publisher
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
publish_html 'Test Report' do
|
|
10
|
+
dir '$BUILD_NUMBER\\Reports'
|
|
11
|
+
file 'test-report.html'
|
|
12
|
+
keep_all false
|
|
13
|
+
allow_missing true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
actual = builder.config_as_xml_node('foo')
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
'reportName' => 'Test Report',
|
|
22
|
+
'reportDir' => '$BUILD_NUMBER\Reports',
|
|
23
|
+
'reportFiles' => 'test-report.html',
|
|
24
|
+
'keepAll' => 'false',
|
|
25
|
+
'allowMissing' => 'true',
|
|
26
|
+
'wrapperName' => 'htmlpublisher-wrapper.html'
|
|
27
|
+
}.each do |k, v|
|
|
28
|
+
assert_equal v, actual.xpath('./project/publishers/htmlpublisher.HtmlPublisher/' \
|
|
29
|
+
"reportTargets/htmlpublisher.HtmlPublisherTarget/#{k}").text, k
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_postbuild_multiple_html_publisher
|
|
34
|
+
builder = JenkinsJob::Builder.new
|
|
35
|
+
|
|
36
|
+
builder.freestyle 'foo' do
|
|
37
|
+
postbuild do
|
|
38
|
+
publish_html 'Test Report' do
|
|
39
|
+
dir '$BUILD_NUMBER\\Reports'
|
|
40
|
+
file 'test-report.html'
|
|
41
|
+
keep_all false
|
|
42
|
+
allow_missing true
|
|
43
|
+
end
|
|
44
|
+
publish_html 'Test Report 2' do
|
|
45
|
+
dir '$BUILD_NUMBER\\Reports'
|
|
46
|
+
file 'test-report-2.html'
|
|
47
|
+
keep_all false
|
|
48
|
+
allow_missing true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
actual = builder.config_as_xml_node('foo')
|
|
54
|
+
|
|
55
|
+
assert_equal 2, actual.xpath('count(./project/publishers/htmlpublisher.HtmlPublisher)').to_i
|
|
56
|
+
end
|
|
57
|
+
end
|
data/test/test_inject.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlInject < Test::Unit::TestCase
|
|
4
|
+
def test_freestyle_inject
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
inject_env do
|
|
9
|
+
properties_content 'EXAMPLE1=foo'
|
|
10
|
+
properties_content 'EXAMPLE2=foo'
|
|
11
|
+
properties_file 'env.prop'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
actual = builder.config_as_xml_node('foo')
|
|
16
|
+
{ 'EnvInjectBuilder/info/propertiesFilePath' => 'env.prop',
|
|
17
|
+
'EnvInjectBuilder/info/propertiesContent' => 'EXAMPLE2=foo',
|
|
18
|
+
}.each do |k, v|
|
|
19
|
+
assert_equal v, actual.xpath('./project/builders/' \
|
|
20
|
+
"#{k}").text, k
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlAnt < Test::Unit::TestCase
|
|
4
|
+
def test_javadoc
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
publish_javadoc do
|
|
10
|
+
doc_dir 'build/doc'
|
|
11
|
+
keep_all false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
actual = builder.config_as_xml_node('foo')
|
|
17
|
+
{ 'keepAll' => 'false',
|
|
18
|
+
'javadocDir' => 'build/doc' }.each do |k, v|
|
|
19
|
+
assert_equal v, actual.xpath("./project/publishers/hudson.tasks.JavadocArchiver/#{k}").text, k
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlLogparser < Test::Unit::TestCase
|
|
4
|
+
def test_postbuild_logparser
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
logparser '/var/lib/jenkins/build_parsing_rules' do
|
|
10
|
+
fail_on_error
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
actual = builder.config_as_xml_node('foo')
|
|
16
|
+
|
|
17
|
+
{ 'unstableOnWarning' => 'false',
|
|
18
|
+
'failBuildOnError' => 'true',
|
|
19
|
+
'parsingRulesPath' => '/var/lib/jenkins/build_parsing_rules'
|
|
20
|
+
}.each do |k, v|
|
|
21
|
+
assert_equal v, actual.xpath("./project/publishers/hudson.plugins.logparser.LogParserPublisher/#{k}").text, k
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlLogrotate < Test::Unit::TestCase
|
|
4
|
+
def test_logrotate
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
logrotate do
|
|
9
|
+
days_to_keep 14
|
|
10
|
+
num_to_keep(-1)
|
|
11
|
+
artifact_days_to_keep 2
|
|
12
|
+
artifact_num_to_keep(-1)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
actual = builder.config_as_xml_node('foo')
|
|
17
|
+
|
|
18
|
+
{ 'daysToKeep' => '14', 'numToKeep' => '-1', 'artifactDaysToKeep' => '2', 'artifactNumToKeep' => '-1' }.each do |k, v|
|
|
19
|
+
assert_equal v, actual.xpath("./project/logRotator/#{k}").text, k
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlMultiJob < Test::Unit::TestCase
|
|
4
|
+
PHASE = './com.tikal.jenkins.plugins.multijob.MultiJobProject' \
|
|
5
|
+
'/builders/com.tikal.jenkins.plugins.multijob.MultiJobBuilder'
|
|
6
|
+
|
|
7
|
+
def test_multi_job
|
|
8
|
+
builder = JenkinsJob::Builder.new
|
|
9
|
+
|
|
10
|
+
builder.multi 'foo' do
|
|
11
|
+
phase 'db' do
|
|
12
|
+
job 'foo_a'
|
|
13
|
+
|
|
14
|
+
job 'foo_b' do
|
|
15
|
+
ignore_result true
|
|
16
|
+
abort_others true
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
phase 'service' do
|
|
21
|
+
job 'foo_c' do
|
|
22
|
+
retries 1
|
|
23
|
+
abort_others false
|
|
24
|
+
end
|
|
25
|
+
job 'foo_d'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
actual = builder.config_as_xml_node('foo')
|
|
30
|
+
|
|
31
|
+
assert_equal %w(db service),
|
|
32
|
+
actual.xpath("#{PHASE}/phaseName").map(&:text)
|
|
33
|
+
|
|
34
|
+
jobs = actual.xpath("#{PHASE}/phaseJobs/com.tikal.jenkins.plugins.multijob.PhaseJobsConfig")
|
|
35
|
+
|
|
36
|
+
assert_equal %w(foo_a foo_b foo_c foo_d),
|
|
37
|
+
jobs.xpath('./jobName').map(&:text)
|
|
38
|
+
|
|
39
|
+
foo_b = jobs.find { |x| x.children.find { |y| y.text == 'foo_b' } }
|
|
40
|
+
assert_equal 'NEVER', foo_b.xpath('./killPhaseOnJobResultCondition').text
|
|
41
|
+
assert_equal 'true', foo_b.xpath('./abortAllJob').text
|
|
42
|
+
|
|
43
|
+
foo_c = jobs.find { |x| x.children.find { |y| y.text == 'foo_c' } }
|
|
44
|
+
assert_equal '1', foo_c.xpath('./maxRetries').text
|
|
45
|
+
assert_equal 'false', foo_c.xpath('./abortAllJob').text
|
|
46
|
+
|
|
47
|
+
assert_equal %w(FAILURE NEVER FAILURE FAILURE),
|
|
48
|
+
actual.xpath("#{PHASE}/phaseJobs/com.tikal.jenkins.plugins.multijob.PhaseJobsConfig/killPhaseOnJobResultCondition").map(&:text)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlNUnitPublisher < Test::Unit::TestCase
|
|
4
|
+
def test_postbuild_nunit_publisher
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
publish_nunit_report 'a\\b'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
actual = builder.config_as_xml_node('foo')
|
|
14
|
+
|
|
15
|
+
{ 'testResultsPattern' => 'a\\b' }.each do |k, v|
|
|
16
|
+
assert_equal v, actual.xpath(
|
|
17
|
+
"./project/publishers/hudson.plugins.nunit.NUnitPublisher/#{k}").text, k
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlParameter < Test::Unit::TestCase
|
|
4
|
+
def test_parameter
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
parameter 'GERRIT_BRANCH' do
|
|
9
|
+
default 'master'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
parameter 'SKIP_TEST' do
|
|
13
|
+
default 'true'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
actual = builder.config_as_xml_node('foo')
|
|
18
|
+
|
|
19
|
+
{ 1 => { 'name' => 'GERRIT_BRANCH', 'defaultValue' => 'master' },
|
|
20
|
+
2 => { 'name' => 'SKIP_TEST', 'defaultValue' => 'true' } }.each do |item, data|
|
|
21
|
+
data.each do |k, v|
|
|
22
|
+
assert_equal v, actual.xpath('./project/properties/hudson.model.ParametersDefinitionProperty/parameterDefinitions/' \
|
|
23
|
+
"hudson.model.StringParameterDefinition[#{item}]/#{k}").text, "item #{item}, #{k}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_password_parameter
|
|
29
|
+
builder = JenkinsJob::Builder.new
|
|
30
|
+
|
|
31
|
+
builder.freestyle 'foo' do
|
|
32
|
+
password_parameter 'PASS' do
|
|
33
|
+
default 'xyz='
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
actual = builder.config_as_xml_node('foo')
|
|
38
|
+
|
|
39
|
+
{ 'name' => 'PASS', 'defaultValue' => 'xyz=' }.each do |k, v|
|
|
40
|
+
assert_equal v, actual.xpath('./project/properties/hudson.model.ParametersDefinitionProperty/parameterDefinitions/' \
|
|
41
|
+
"hudson.model.PasswordParameterDefinition/#{k}").text
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlPassword < Test::Unit::TestCase
|
|
4
|
+
def test_password
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
password 'ADMIN_PASS', 'PhxHFCjgSiXR2umXhALLq+RzqJBxODDJT4t9Tw5JXbI='
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
actual = builder.config_as_xml_node('foo')
|
|
12
|
+
|
|
13
|
+
{ 'name' => 'ADMIN_PASS', 'value' => 'PhxHFCjgSiXR2umXhALLq+RzqJBxODDJT4t9Tw5JXbI=' }.each do |k, v|
|
|
14
|
+
assert v, actual.xpath("./project/buildWrappers/EnvInjectPasswordWrapper/passwordEntries/EnvInjectPasswordEntry/#{k}").text
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/test/test_pmd.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlAnt < Test::Unit::TestCase
|
|
4
|
+
def test_javadoc
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
publish_pmd do
|
|
10
|
+
pmd_results 'build/phppmd.txt'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
actual = builder.config_as_xml_node('foo')
|
|
16
|
+
{ 'pattern' => 'build/phppmd.txt',
|
|
17
|
+
'thresholdLimit' => 'low',
|
|
18
|
+
'pluginName' => '[PMD]' }.each do |k, v|
|
|
19
|
+
assert_equal v, actual.xpath("./project/publishers/hudson.plugins.pmd.PmdPublisher/#{k}").text, k
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlPollSCM < Test::Unit::TestCase
|
|
4
|
+
def test_pollscm
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
pollscm '*/5 * * * *'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
actual = builder.config_as_xml_node('foo')
|
|
12
|
+
|
|
13
|
+
assert_equal '*/5 * * * *', actual.xpath('./project/triggers/hudson.triggers.SCMTrigger/spec').text
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlPostbuildGroovy < Test::Unit::TestCase
|
|
4
|
+
def test_postbuild_groovy
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
groovy 'manager.buildFailure()'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
actual = builder.config_as_xml_node('foo')
|
|
14
|
+
|
|
15
|
+
assert_equal 'manager.buildFailure()', actual.xpath('./project/publishers/' \
|
|
16
|
+
'org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder/groovyScript').text
|
|
17
|
+
|
|
18
|
+
assert_equal '0', actual.xpath('./project/publishers/' \
|
|
19
|
+
'org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder/behavior').text
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlPostbuildScript < Test::Unit::TestCase
|
|
4
|
+
def test_postbuild_shell
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
shell 'cd Reports && mv $(ls *.xml) merge.xml'
|
|
10
|
+
batch 'hostname'
|
|
11
|
+
powershell 'Write-Host "hello world"'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
actual = builder.config_as_xml_node('foo')
|
|
16
|
+
{ 'hudson.tasks.Shell/command' => 'cd Reports && mv $(ls *.xml) merge.xml',
|
|
17
|
+
'hudson.tasks.BatchFile/command' => 'hostname',
|
|
18
|
+
'hudson.plugins.powershell.PowerShell/command' => 'Write-Host "hello world"',
|
|
19
|
+
}.each do |k, v|
|
|
20
|
+
assert_equal v, actual.xpath('./project/publishers/' \
|
|
21
|
+
"org.jenkinsci.plugins.postbuildscript.PostBuildScript/buildSteps/#{k}").text, k
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlPostbuildTrigger < Test::Unit::TestCase
|
|
4
|
+
ROOT = './project/publishers/hudson.plugins.parameterizedtrigger.BuildTrigger/configs'
|
|
5
|
+
TRIGGER_CONFIG = 'hudson.plugins.parameterizedtrigger.BuildTriggerConfig'
|
|
6
|
+
|
|
7
|
+
def test_postbuild_trigger
|
|
8
|
+
builder = JenkinsJob::Builder.new
|
|
9
|
+
|
|
10
|
+
builder.freestyle 'foo' do
|
|
11
|
+
postbuild do
|
|
12
|
+
trigger 'bar' do
|
|
13
|
+
trigger_with_no_parameters true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
actual = builder.config_as_xml_node('foo')
|
|
19
|
+
|
|
20
|
+
expected_trigger_configuration = {
|
|
21
|
+
'projects' => 'bar',
|
|
22
|
+
'condition' => 'SUCCESS',
|
|
23
|
+
'triggerWithNoParameters' => 'true'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
expected_trigger_configuration.each do |key, expected_value|
|
|
27
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/#{key}").text
|
|
28
|
+
assert_equal expected_value, given_value, key
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_postbuild_trigger_multiple_projects
|
|
33
|
+
builder = JenkinsJob::Builder.new
|
|
34
|
+
|
|
35
|
+
builder.freestyle 'foo' do
|
|
36
|
+
postbuild do
|
|
37
|
+
trigger 'bar1', 'bar2' do
|
|
38
|
+
trigger_with_no_parameters true
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
actual = builder.config_as_xml_node('foo')
|
|
44
|
+
|
|
45
|
+
expected_trigger_configuration = {
|
|
46
|
+
'projects' => 'bar1,bar2',
|
|
47
|
+
'condition' => 'SUCCESS',
|
|
48
|
+
'triggerWithNoParameters' => 'true'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
expected_trigger_configuration.each do |key, expected_value|
|
|
52
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/#{key}").text
|
|
53
|
+
assert_equal expected_value, given_value, key
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_trigger_paramaterized_with_file
|
|
58
|
+
expected_file_build_tag = 'hudson.plugins.parameterizedtrigger.FileBuildParameters'
|
|
59
|
+
builder = JenkinsJob::Builder.new
|
|
60
|
+
|
|
61
|
+
builder.freestyle 'foo' do
|
|
62
|
+
postbuild do
|
|
63
|
+
trigger 'bar' do
|
|
64
|
+
file 'env.properties'
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
expected_file_parameters = {
|
|
70
|
+
'propertiesFile' => 'env.properties',
|
|
71
|
+
'failTriggerOnMissing' => 'false',
|
|
72
|
+
'useMatrixChild' => 'false',
|
|
73
|
+
'onlyExactRuns' => 'false'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
expected_trigger_configuration = {
|
|
77
|
+
'projects' => 'bar',
|
|
78
|
+
'condition' => 'SUCCESS',
|
|
79
|
+
'triggerWithNoParameters' => 'false'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
actual = builder.config_as_xml_node('foo')
|
|
83
|
+
|
|
84
|
+
expected_trigger_configuration.each do |key, expected_value|
|
|
85
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/#{key}").text
|
|
86
|
+
assert_equal expected_value, given_value, key
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
expected_file_parameters.each do |key, expected_value|
|
|
90
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/configs/#{expected_file_build_tag}/#{key}").text
|
|
91
|
+
assert_equal expected_value, given_value, key
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_trigger_paramaterized_with_current_parameters
|
|
96
|
+
builder = JenkinsJob::Builder.new
|
|
97
|
+
|
|
98
|
+
builder.freestyle 'foo' do
|
|
99
|
+
postbuild do
|
|
100
|
+
trigger 'bar' do
|
|
101
|
+
current_parameters true
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
actual = builder.config_as_xml_node('foo')
|
|
107
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/configs").children.to_s.strip
|
|
108
|
+
expected_config = '<hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>'
|
|
109
|
+
assert_equal expected_config, given_value, 'config'
|
|
110
|
+
|
|
111
|
+
expected_trigger_configuration = {
|
|
112
|
+
'projects' => 'bar',
|
|
113
|
+
'condition' => 'SUCCESS',
|
|
114
|
+
'triggerWithNoParameters' => 'false'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
expected_trigger_configuration.each do |key, expected_value|
|
|
118
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/#{key}").text
|
|
119
|
+
assert_equal expected_value, given_value, key
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_trigger_paramaterized_with_predefined_parameters
|
|
124
|
+
expected_predefined_build_tag = 'hudson.plugins.parameterizedtrigger.PredefinedBuildParameters'
|
|
125
|
+
builder = JenkinsJob::Builder.new
|
|
126
|
+
builder.freestyle 'foo' do
|
|
127
|
+
postbuild do
|
|
128
|
+
trigger 'bar' do
|
|
129
|
+
predefined_parameters 'BUILD_NUM' => '${BUILD_NUMBER}',
|
|
130
|
+
'PACKAGE_VERSION' => '${PACKAGE_VERSION}'
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
actual = builder.config_as_xml_node('foo')
|
|
136
|
+
|
|
137
|
+
expected_predefined_parameters = { 'properties' => "BUILD_NUM=${BUILD_NUMBER}\nPACKAGE_VERSION=${PACKAGE_VERSION}" }
|
|
138
|
+
expected_predefined_parameters.each do |key, expected_value|
|
|
139
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/configs/#{expected_predefined_build_tag}/#{key}").text
|
|
140
|
+
assert_equal expected_value, given_value, key
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
expected_trigger_configuration = {
|
|
144
|
+
'projects' => 'bar',
|
|
145
|
+
'condition' => 'SUCCESS',
|
|
146
|
+
'triggerWithNoParameters' => 'false'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
expected_trigger_configuration.each do |key, expected_value|
|
|
150
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/#{key}").text
|
|
151
|
+
assert_equal expected_value, given_value, key
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_trigger_paramaterized_with_pass_through_git_commit
|
|
156
|
+
builder = JenkinsJob::Builder.new
|
|
157
|
+
builder.freestyle 'foo' do
|
|
158
|
+
postbuild do
|
|
159
|
+
trigger 'bar' do
|
|
160
|
+
pass_through_git_commit
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
actual = builder.config_as_xml_node('foo')
|
|
166
|
+
|
|
167
|
+
given_value = actual.xpath("#{ROOT}/#{TRIGGER_CONFIG}/configs/hudson.plugins.git.GitRevisionBuildParameters/combineQueuedCommits").text
|
|
168
|
+
assert_equal 'true', given_value
|
|
169
|
+
end
|
|
170
|
+
end
|
data/test/test_scms.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlScms < Test::Unit::TestCase
|
|
4
|
+
def test_git
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
scms do
|
|
9
|
+
git do
|
|
10
|
+
url 'ssh://bar@gerrit.mycompany.com:29418/a'
|
|
11
|
+
basedir 'a'
|
|
12
|
+
branches '*/master'
|
|
13
|
+
clean true
|
|
14
|
+
end
|
|
15
|
+
git do
|
|
16
|
+
url 'ssh://bar@gerrit.mycompany.com:29418/b'
|
|
17
|
+
basedir 'b'
|
|
18
|
+
branches '*/master'
|
|
19
|
+
clean true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
actual = builder.config_as_xml_node('foo')
|
|
25
|
+
|
|
26
|
+
expected_class = 'org.jenkinsci.plugins.multiplescms.MultiSCM'
|
|
27
|
+
expected_scm = 'scm'
|
|
28
|
+
scm_nodes = "./project/scm[contains(@class,'#{expected_class}') and @plugin='multiple-scms@0.3']/scms/#{expected_scm}"
|
|
29
|
+
assert_equal 2, actual.xpath("count(#{scm_nodes})").to_i
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require_relative './test_xml_generator'
|
|
2
|
+
|
|
3
|
+
class TestXmlXTapPublisher < Test::Unit::TestCase
|
|
4
|
+
def test_postbuild_tap_publisher
|
|
5
|
+
builder = JenkinsJob::Builder.new
|
|
6
|
+
|
|
7
|
+
builder.freestyle 'foo' do
|
|
8
|
+
postbuild do
|
|
9
|
+
publish_tap 'TestResultsInTapFormat.tap' do
|
|
10
|
+
verbose true
|
|
11
|
+
require_plan true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
actual = builder.config_as_xml_node('foo')
|
|
17
|
+
|
|
18
|
+
{ 'testResults' => 'TestResultsInTapFormat.tap',
|
|
19
|
+
'verbose' => 'true',
|
|
20
|
+
'require_plan' => 'true'
|
|
21
|
+
}.each do |k, v|
|
|
22
|
+
assert v, actual.xpath("./project/publishers/org.tap4j.plugin.TapPublisher/#{k}").text
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|