rubyjobbuilderdsl 0.0.5 → 0.0.6

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.
Files changed (111) hide show
  1. checksums.yaml +13 -5
  2. data/Gemfile +6 -6
  3. data/Gemfile.lock +41 -41
  4. data/LICENSE +18 -18
  5. data/Rakefile +12 -12
  6. data/docs/common.md +313 -313
  7. data/docs/flow.md +17 -17
  8. data/docs/freestyle.md +100 -100
  9. data/docs/gerrit.md +70 -70
  10. data/docs/git.md +88 -88
  11. data/docs/multi.md +26 -26
  12. data/docs/overview.md +74 -74
  13. data/docs/postbuild.md +266 -266
  14. data/docs/view.md +13 -13
  15. data/lib/rubyjobbuilderdsl.rb +2 -2
  16. data/lib/rubyjobbuilderdsl/buildstep/ant.rb +29 -29
  17. data/lib/rubyjobbuilderdsl/buildstep/copyartifact.rb +23 -23
  18. data/lib/rubyjobbuilderdsl/buildstep/inject_env.rb +18 -18
  19. data/lib/rubyjobbuilderdsl/buildstep/phase.rb +19 -19
  20. data/lib/rubyjobbuilderdsl/buildstep/phase_job.rb +26 -26
  21. data/lib/rubyjobbuilderdsl/buildstep/shell.rb +24 -24
  22. data/lib/rubyjobbuilderdsl/buildstep/xvfb.rb +46 -46
  23. data/lib/rubyjobbuilderdsl/common.rb +140 -140
  24. data/lib/rubyjobbuilderdsl/common/artifactory.rb +33 -33
  25. data/lib/rubyjobbuilderdsl/common/blocking_job.rb +11 -11
  26. data/lib/rubyjobbuilderdsl/common/build_timeout.rb +23 -23
  27. data/lib/rubyjobbuilderdsl/common/gerrit.rb +53 -53
  28. data/lib/rubyjobbuilderdsl/common/git.rb +76 -76
  29. data/lib/rubyjobbuilderdsl/common/logrotate.rb +24 -24
  30. data/lib/rubyjobbuilderdsl/common/parameter.rb +22 -22
  31. data/lib/rubyjobbuilderdsl/common/password.rb +12 -12
  32. data/lib/rubyjobbuilderdsl/common/pollscm.rb +10 -10
  33. data/lib/rubyjobbuilderdsl/common/scms.rb +18 -18
  34. data/lib/rubyjobbuilderdsl/common/throttle.rb +24 -24
  35. data/lib/rubyjobbuilderdsl/common/timed.rb +10 -10
  36. data/lib/rubyjobbuilderdsl/common/timestamps.rb +6 -6
  37. data/lib/rubyjobbuilderdsl/deployer.rb +95 -95
  38. data/lib/rubyjobbuilderdsl/flow.rb +14 -14
  39. data/lib/rubyjobbuilderdsl/freestyle.rb +65 -65
  40. data/lib/rubyjobbuilderdsl/jenkins_client.rb +203 -203
  41. data/lib/rubyjobbuilderdsl/multijob.rb +24 -24
  42. data/lib/rubyjobbuilderdsl/postbuild.rb +160 -160
  43. data/lib/rubyjobbuilderdsl/postbuild/archive.rb +23 -23
  44. data/lib/rubyjobbuilderdsl/postbuild/chucknorris_publisher.rb +6 -6
  45. data/lib/rubyjobbuilderdsl/postbuild/claim_publisher.rb +6 -6
  46. data/lib/rubyjobbuilderdsl/postbuild/cloverphp_publisher.rb +36 -36
  47. data/lib/rubyjobbuilderdsl/postbuild/cucumber_json_publisher.rb +20 -20
  48. data/lib/rubyjobbuilderdsl/postbuild/email_publisher.rb +23 -23
  49. data/lib/rubyjobbuilderdsl/postbuild/game_publisher.rb +6 -6
  50. data/lib/rubyjobbuilderdsl/postbuild/groovy.rb +10 -10
  51. data/lib/rubyjobbuilderdsl/postbuild/html_publisher.rb +27 -27
  52. data/lib/rubyjobbuilderdsl/postbuild/javadoc_publisher.rb +19 -19
  53. data/lib/rubyjobbuilderdsl/postbuild/logparser.rb +21 -21
  54. data/lib/rubyjobbuilderdsl/postbuild/nunit_publisher.rb +21 -21
  55. data/lib/rubyjobbuilderdsl/postbuild/pmd_publisher.rb +19 -19
  56. data/lib/rubyjobbuilderdsl/postbuild/script.rb +14 -14
  57. data/lib/rubyjobbuilderdsl/postbuild/tap_publisher.rb +44 -44
  58. data/lib/rubyjobbuilderdsl/postbuild/trigger.rb +38 -38
  59. data/lib/rubyjobbuilderdsl/postbuild/xunit_publisher.rb +35 -35
  60. data/lib/rubyjobbuilderdsl/view.rb +14 -14
  61. data/lib/rubyjobbuilderdsl/xml_generator.rb +1 -1
  62. data/rubyjobbuilderdsl.gemspec +2 -2
  63. data/rubyjobbuilderdsl.sublime-project +14 -14
  64. data/run_tests.sh +7 -7
  65. data/sample/hello_mars.rb +27 -27
  66. data/sample/hello_mars.xml +18 -0
  67. data/sample/hello_world-post.xml +40 -0
  68. data/sample/local.ini +4 -4
  69. data/sample/test.xml +21 -0
  70. data/test/test_ant.rb +38 -38
  71. data/test/test_archive.rb +24 -24
  72. data/test/test_artifactory.rb +26 -26
  73. data/test/test_blocking_job.rb +18 -18
  74. data/test/test_chucknorris_publisher.rb +17 -17
  75. data/test/test_claim_publisher.rb +17 -17
  76. data/test/test_cloverphp.rb +33 -33
  77. data/test/test_concurrent.rb +44 -44
  78. data/test/test_copyartifact.rb +45 -45
  79. data/test/test_cucumber_json_publisher.rb +30 -30
  80. data/test/test_default_setting.rb +29 -29
  81. data/test/test_email_publisher.rb +44 -44
  82. data/test/test_flow.rb +19 -19
  83. data/test/test_freestyle.rb +52 -52
  84. data/test/test_game_publisher.rb +17 -17
  85. data/test/test_gerrit.rb +117 -117
  86. data/test/test_git.rb +80 -80
  87. data/test/test_html_publisher.rb +57 -57
  88. data/test/test_inject.rb +23 -23
  89. data/test/test_javadoc.rb +22 -22
  90. data/test/test_logparser.rb +24 -24
  91. data/test/test_logrotate.rb +22 -22
  92. data/test/test_multijob.rb +50 -50
  93. data/test/test_nunit_publisher.rb +20 -20
  94. data/test/test_parameter.rb +44 -44
  95. data/test/test_password.rb +17 -17
  96. data/test/test_pmd.rb +22 -22
  97. data/test/test_pollscm.rb +15 -15
  98. data/test/test_postbuild_groovy.rb +21 -21
  99. data/test/test_postbuild_script.rb +24 -24
  100. data/test/test_postbuild_trigger.rb +170 -170
  101. data/test/test_scms.rb +31 -31
  102. data/test/test_tap_publisher.rb +25 -25
  103. data/test/test_timed.rb +15 -15
  104. data/test/test_timeout.rb +20 -20
  105. data/test/test_timestamps.rb +14 -14
  106. data/test/test_xml_generator.rb +28 -28
  107. data/test/test_xunit_publisher.rb +22 -22
  108. data/test/test_xvfb.rb +35 -35
  109. metadata +11 -10
  110. data/rubyjobbuilderdsl-0.0.3.gem +0 -0
  111. data/sample/Schedule-sample-pipeline.xml +0 -32
@@ -1,38 +1,38 @@
1
- module JenkinsJob
2
- module Postbuild
3
- class PostbuildTrigger < BasicObject
4
- attr_reader :project_, :fail_on_missing_, :file_,
5
- :predefined_parameters_, :current_parameters_, :trigger_with_no_parameters_,
6
- :pass_through_git_commit_
7
-
8
- def initialize(*project)
9
- @project_ = project
10
- @trigger_with_no_parameters_ = false
11
- end
12
-
13
- def fail_on_missing(value = false)
14
- @fail_on_missing_ = value
15
- end
16
-
17
- def file(value)
18
- @file_ = value
19
- end
20
-
21
- def predefined_parameters(value)
22
- @predefined_parameters_ = value.map { |key, val| "#{key}=#{val}" }.join("\n")
23
- end
24
-
25
- def current_parameters(value)
26
- @current_parameters_ = value
27
- end
28
-
29
- def trigger_with_no_parameters(value)
30
- @trigger_with_no_parameters_ = value
31
- end
32
-
33
- def pass_through_git_commit(value = true)
34
- @pass_through_git_commit_ = value
35
- end
36
- end
37
- end
38
- end
1
+ module JenkinsJob
2
+ module Postbuild
3
+ class PostbuildTrigger < BasicObject
4
+ attr_reader :project_, :fail_on_missing_, :file_,
5
+ :predefined_parameters_, :current_parameters_, :trigger_with_no_parameters_,
6
+ :pass_through_git_commit_
7
+
8
+ def initialize(*project)
9
+ @project_ = project
10
+ @trigger_with_no_parameters_ = false
11
+ end
12
+
13
+ def fail_on_missing(value = false)
14
+ @fail_on_missing_ = value
15
+ end
16
+
17
+ def file(value)
18
+ @file_ = value
19
+ end
20
+
21
+ def predefined_parameters(value)
22
+ @predefined_parameters_ = value.map { |key, val| "#{key}=#{val}" }.join("\n")
23
+ end
24
+
25
+ def current_parameters(value)
26
+ @current_parameters_ = value
27
+ end
28
+
29
+ def trigger_with_no_parameters(value)
30
+ @trigger_with_no_parameters_ = value
31
+ end
32
+
33
+ def pass_through_git_commit(value = true)
34
+ @pass_through_git_commit_ = value
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,35 +1,35 @@
1
- # dsl methods for job builder
2
- module JenkinsJob
3
- module Postbuild
4
- class XUnitPublisher < BasicObject
5
- attr_reader :test_results_pattern_,
6
- :failed_threshold_, :unstable_threshold_
7
-
8
- THRESH_HOLDS = [:total_failed_tests, :new_failed_tests,
9
- :total_skipped_tests, :new_skipped_tests]
10
-
11
- def initialize(test_results_pattern)
12
- @test_results_pattern_ = test_results_pattern
13
-
14
- @debug_ = false
15
- @keep_junit_reports_ = false
16
- @skip_junit_archiver_ = false
17
-
18
- @failed_threshold_ = {}
19
- @unstable_threshold_ = {}
20
- end
21
-
22
- def test_results_pattern(value)
23
- @test_results_pattern_ = value
24
- end
25
-
26
- def failed_threshold(params = {})
27
- @failed_threshold_ = params
28
- end
29
-
30
- def unstable_threshold(params = {})
31
- @unstable_threshold_ = params
32
- end
33
- end
34
- end
35
- end
1
+ # dsl methods for job builder
2
+ module JenkinsJob
3
+ module Postbuild
4
+ class XUnitPublisher < BasicObject
5
+ attr_reader :test_results_pattern_,
6
+ :failed_threshold_, :unstable_threshold_
7
+
8
+ THRESH_HOLDS = [:total_failed_tests, :new_failed_tests,
9
+ :total_skipped_tests, :new_skipped_tests]
10
+
11
+ def initialize(test_results_pattern)
12
+ @test_results_pattern_ = test_results_pattern
13
+
14
+ @debug_ = false
15
+ @keep_junit_reports_ = false
16
+ @skip_junit_archiver_ = false
17
+
18
+ @failed_threshold_ = {}
19
+ @unstable_threshold_ = {}
20
+ end
21
+
22
+ def test_results_pattern(value)
23
+ @test_results_pattern_ = value
24
+ end
25
+
26
+ def failed_threshold(params = {})
27
+ @failed_threshold_ = params
28
+ end
29
+
30
+ def unstable_threshold(params = {})
31
+ @unstable_threshold_ = params
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,14 +1,14 @@
1
- module JenkinsJob
2
- class View
3
- attr_reader :name, :jobname_
4
-
5
- def initialize(name, builder)
6
- @builder = builder
7
- @name = name
8
- end
9
-
10
- def job(regex)
11
- @jobname_ = regex
12
- end
13
- end
14
- end
1
+ module JenkinsJob
2
+ class View
3
+ attr_reader :name, :jobname_
4
+
5
+ def initialize(name, builder)
6
+ @builder = builder
7
+ @name = name
8
+ end
9
+
10
+ def job(regex)
11
+ @jobname_ = regex
12
+ end
13
+ end
14
+ end
@@ -438,7 +438,7 @@ module JenkinsJob
438
438
 
439
439
  def generate_build_timeout(model, wrappers)
440
440
  wrappers.tag!('hudson.plugins.build__timeout.BuildTimeoutWrapper') do |timeout|
441
- timeout.timeoutMinutes(10)
441
+ timeout.timeoutMinutes(15)
442
442
  timeout.failBuild(false)
443
443
  timeout.writingDescription(false)
444
444
  timeout.timeoutType(model.type_)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rubyjobbuilderdsl'
3
- s.version = '0.0.5'
4
- s.date = '2017-10-16'
3
+ s.version = '0.0.6'
4
+ s.date = '2017-10-19'
5
5
  s.summary = 'Ruby Internal DSL for creating Jenkins jobs'
6
6
  s.description = 'Ruby Internal DSL for creating Jenkins jobs'
7
7
  s.authors = ['Huy Le']
@@ -1,14 +1,14 @@
1
- {
2
- "folders":
3
- [
4
- {
5
- "path": ".",
6
- "folder_exclude_patterns": [".bundle", "vendor"]
7
- }
8
- ],
9
- "settings":
10
- {
11
- "tab_size": 2,
12
- "translate_tabs_to_spaces": true
13
- }
14
- }
1
+ {
2
+ "folders":
3
+ [
4
+ {
5
+ "path": ".",
6
+ "folder_exclude_patterns": [".bundle", "vendor"]
7
+ }
8
+ ],
9
+ "settings":
10
+ {
11
+ "tab_size": 2,
12
+ "translate_tabs_to_spaces": true
13
+ }
14
+ }
data/run_tests.sh CHANGED
@@ -1,7 +1,7 @@
1
- #!/bin/sh
2
-
3
- set -ex
4
-
5
- bundle install --deployment
6
-
7
- bundle exec rake
1
+ #!/bin/sh
2
+
3
+ set -ex
4
+
5
+ bundle install --deployment
6
+
7
+ bundle exec rake
data/sample/hello_mars.rb CHANGED
@@ -1,27 +1,27 @@
1
- require_relative '../lib/rubyjobbuilderdsl'
2
-
3
- builder = JenkinsJob::Builder.new
4
-
5
- builder.freestyle 'hello_mars' do
6
- shell 'echo hello mars > hello_mars-1.0.$BUILD_NUMBER.txt && gzip hello_mars-1.0.$BUILD_NUMBER.txt'
7
- end
8
-
9
- builder.view 'test' do
10
- job 'test-.*'
11
- end
12
-
13
- JenkinsJob::Deployer.new(builder).run do
14
- disable_job 'hello_mars'
15
- wipeout_workspace 'hello_mars'
16
- delete_job 'hello_mars'
17
- delete_view 'test'
18
-
19
- each do |name, xml, type|
20
- upload_view(name, xml) if type == :view
21
- upload_job(name, xml) if type == :job
22
- end
23
-
24
- groovysh 'println "hello world"'
25
- enable_job 'hello_mars'
26
- trigger_job 'hello_mars'
27
- end
1
+ require_relative '../lib/rubyjobbuilderdsl'
2
+
3
+ builder = JenkinsJob::Builder.new
4
+
5
+ builder.freestyle 'hello_mars' do
6
+ shell 'echo hello mars > hello_mars-1.0.$BUILD_NUMBER.txt && gzip hello_mars-1.0.$BUILD_NUMBER.txt'
7
+ end
8
+
9
+ builder.view 'test' do
10
+ job 'test-.*'
11
+ end
12
+
13
+ JenkinsJob::Deployer.new(builder).run do
14
+ disable_job 'hello_mars'
15
+ wipeout_workspace 'hello_mars'
16
+ delete_job 'hello_mars'
17
+ delete_view 'test'
18
+
19
+ each do |name, xml, type|
20
+ upload_view(name, xml) if type == :view
21
+ upload_job(name, xml) if type == :job
22
+ end
23
+
24
+ groovysh 'println "hello world"'
25
+ enable_job 'hello_mars'
26
+ trigger_job 'hello_mars'
27
+ end
@@ -0,0 +1,18 @@
1
+ <project>
2
+ <actions/>
3
+ <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
4
+ <keepDependencies>false</keepDependencies>
5
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
6
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
7
+ <concurrentBuild>false</concurrentBuild>
8
+ <canRoam>true</canRoam>
9
+ <properties/>
10
+ <scm class="hudson.scm.NullSCM"/>
11
+ <publishers/>
12
+ <buildWrappers/>
13
+ <builders>
14
+ <hudson.tasks.Shell>
15
+ <command>echo hello mars &gt; hello_mars-1.0.$BUILD_NUMBER.txt &amp;&amp; gzip hello_mars-1.0.$BUILD_NUMBER.txt</command>
16
+ </hudson.tasks.Shell>
17
+ </builders>
18
+ </project>
@@ -0,0 +1,40 @@
1
+ <flow-definition plugin="workflow-job@2.11">
2
+ <actions/>
3
+ <description/>
4
+ <keepDependencies>false</keepDependencies>
5
+ <properties>
6
+ <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
7
+ <triggers/>
8
+ </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
9
+ </properties>
10
+ <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.32">
11
+ <script>build("hello_world",
12
+ SOME_PARAM: "A_param_value")
13
+ </script>
14
+ </definition>
15
+ <disabled>false</disabled>
16
+ <publishers>
17
+ <jenkins.plugins.slack.SlackNotifier plugin="slack@2.3">
18
+ <baseUrl>This is base url</baseUrl>
19
+ <teamDomain/>
20
+ <authToken>This is an auth_token</authToken>
21
+ <authTokenCredentialId/>
22
+ <botUser>false</botUser>
23
+ <room/>
24
+ <startNotification>true</startNotification>
25
+ <notifySuccess>true</notifySuccess>
26
+ <notifyAborted>true</notifyAborted>
27
+ <notifyNotBuilt>false</notifyNotBuilt>
28
+ <notifyUnstable>false</notifyUnstable>
29
+ <notifyRegression>false</notifyRegression>
30
+ <notifyFailure>true</notifyFailure>
31
+ <notifyBackToNormal>false</notifyBackToNormal>
32
+ <notifyRepeatedFailure>false</notifyRepeatedFailure>
33
+ <includeTestSummary>false</includeTestSummary>
34
+ <includeFailedTests>false</includeFailedTests>
35
+ <commitInfoChoice>NONE</commitInfoChoice>
36
+ <includeCustomMessage>false</includeCustomMessage>
37
+ <CustomMessage/>
38
+ </jenkins.plugins.slack.SlackNotifier>
39
+ </publishers>
40
+ </flow-definition>
data/sample/local.ini CHANGED
@@ -1,4 +1,4 @@
1
- [jenkins]
2
- url=http://localhost:8080/
3
- user=jenkins-jobs
4
- password=7bb352e4f3da683c17247f3abf88f47c
1
+ [jenkins]
2
+ url=http://localhost:8080/
3
+ user=jenkins-jobs
4
+ password=7bb352e4f3da683c17247f3abf88f47c
data/sample/test.xml ADDED
@@ -0,0 +1,21 @@
1
+ <hudson.model.ListView>
2
+ <name>test</name>
3
+ <filterExecutors>false</filterExecutors>
4
+ <filterQueue>false</filterQueue>
5
+ <properties class="hudson.model.View$PropertyList"/>
6
+ <jobNames>
7
+ <comparator class="hudson.util.CaseInsensitiveComparator"/>
8
+ </jobNames>
9
+ <jobFilters/>
10
+ <columns>
11
+ <hudson.views.StatusColumn/>
12
+ <hudson.views.WeatherColumn/>
13
+ <hudson.views.JobColumn/>
14
+ <hudson.views.LastSuccessColumn/>
15
+ <hudson.views.LastFailureColumn/>
16
+ <hudson.views.LastDurationColumn/>
17
+ <hudson.views.BuildButtonColumn/>
18
+ </columns>
19
+ <includeRegex>test-.*</includeRegex>
20
+ <recurse>false</recurse>
21
+ </hudson.model.ListView>
data/test/test_ant.rb CHANGED
@@ -1,38 +1,38 @@
1
- require_relative './test_xml_generator'
2
-
3
- class TestXmlAnt < Test::Unit::TestCase
4
- def test_ant
5
- builder = JenkinsJob::Builder.new
6
-
7
- builder.freestyle 'foo' do
8
- ant do
9
- target 'clean', 'lint'
10
- buildfile 'foo.xml'
11
- java_opts '-Xmx512m', '-Xms512m'
12
- property 'skipTest' => 'false'
13
- end
14
- end
15
-
16
- actual = builder.config_as_xml_node('foo')
17
- { 'hudson.tasks.Ant/targets' => 'clean lint',
18
- 'hudson.tasks.Ant/buildFile' => 'foo.xml',
19
- 'hudson.tasks.Ant/properties' => '-DskipTest=false',
20
- 'hudson.tasks.Ant/antOpts' => '-Xmx512m -Xms512m',
21
- }.each do |k, v|
22
- assert_equal v, actual.xpath('./project/builders/' \
23
- "#{k}").text, k
24
- end
25
- end
26
-
27
- def test_ant_defalt_target
28
- builder = JenkinsJob::Builder.new
29
-
30
- builder.freestyle 'foo' do
31
- ant do
32
- end
33
- end
34
-
35
- actual = builder.config_as_xml_node('foo')
36
- assert actual.at('./project/builders/hudson.tasks.Ant/targets')
37
- end
38
- end
1
+ require_relative './test_xml_generator'
2
+
3
+ class TestXmlAnt < Test::Unit::TestCase
4
+ def test_ant
5
+ builder = JenkinsJob::Builder.new
6
+
7
+ builder.freestyle 'foo' do
8
+ ant do
9
+ target 'clean', 'lint'
10
+ buildfile 'foo.xml'
11
+ java_opts '-Xmx512m', '-Xms512m'
12
+ property 'skipTest' => 'false'
13
+ end
14
+ end
15
+
16
+ actual = builder.config_as_xml_node('foo')
17
+ { 'hudson.tasks.Ant/targets' => 'clean lint',
18
+ 'hudson.tasks.Ant/buildFile' => 'foo.xml',
19
+ 'hudson.tasks.Ant/properties' => '-DskipTest=false',
20
+ 'hudson.tasks.Ant/antOpts' => '-Xmx512m -Xms512m',
21
+ }.each do |k, v|
22
+ assert_equal v, actual.xpath('./project/builders/' \
23
+ "#{k}").text, k
24
+ end
25
+ end
26
+
27
+ def test_ant_defalt_target
28
+ builder = JenkinsJob::Builder.new
29
+
30
+ builder.freestyle 'foo' do
31
+ ant do
32
+ end
33
+ end
34
+
35
+ actual = builder.config_as_xml_node('foo')
36
+ assert actual.at('./project/builders/hudson.tasks.Ant/targets')
37
+ end
38
+ end