jenkins_pipeline_builder 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +4 -0
  5. data/Rakefile +68 -0
  6. data/bin/generate +28 -0
  7. data/config/login.yml +24 -0
  8. data/jenkins_pipeline_builder.gemspec +42 -0
  9. data/lib/jenksin_pipeline_builder.rb +39 -0
  10. data/lib/jenksin_pipeline_builder/builders.rb +72 -0
  11. data/lib/jenksin_pipeline_builder/cli/base.rb +69 -0
  12. data/lib/jenksin_pipeline_builder/cli/helper.rb +68 -0
  13. data/lib/jenksin_pipeline_builder/cli/pipeline.rb +40 -0
  14. data/lib/jenksin_pipeline_builder/cli/view.rb +40 -0
  15. data/lib/jenksin_pipeline_builder/compiler.rb +81 -0
  16. data/lib/jenksin_pipeline_builder/generator.rb +346 -0
  17. data/lib/jenksin_pipeline_builder/job_builder.rb +82 -0
  18. data/lib/jenksin_pipeline_builder/module_registry.rb +82 -0
  19. data/lib/jenksin_pipeline_builder/publishers.rb +113 -0
  20. data/lib/jenksin_pipeline_builder/triggers.rb +38 -0
  21. data/lib/jenksin_pipeline_builder/utils.rb +46 -0
  22. data/lib/jenksin_pipeline_builder/version.rb +25 -0
  23. data/lib/jenksin_pipeline_builder/view.rb +259 -0
  24. data/lib/jenksin_pipeline_builder/wrappers.rb +91 -0
  25. data/lib/jenksin_pipeline_builder/xml_helper.rb +40 -0
  26. data/spec/func_tests/spec_helper.rb +18 -0
  27. data/spec/func_tests/view_spec.rb +93 -0
  28. data/spec/unit_tests/compiler_spec.rb +19 -0
  29. data/spec/unit_tests/fixtures/files/Job-Build-Flow.xml +57 -0
  30. data/spec/unit_tests/fixtures/files/Job-Build-Flow.yaml +22 -0
  31. data/spec/unit_tests/fixtures/files/Job-Build-Maven.xml +90 -0
  32. data/spec/unit_tests/fixtures/files/Job-Build-Maven.yaml +26 -0
  33. data/spec/unit_tests/fixtures/files/Job-DSL.yaml +14 -0
  34. data/spec/unit_tests/fixtures/files/Job-DSL1.xml +27 -0
  35. data/spec/unit_tests/fixtures/files/Job-DSL2.xml +25 -0
  36. data/spec/unit_tests/fixtures/files/Job-Gem-Build.xml +142 -0
  37. data/spec/unit_tests/fixtures/files/Job-Gem-Build.yaml +41 -0
  38. data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.xml +32 -0
  39. data/spec/unit_tests/fixtures/files/Job-Generate-From-Template.yaml +8 -0
  40. data/spec/unit_tests/fixtures/files/Job-Multi-Project.xml +117 -0
  41. data/spec/unit_tests/fixtures/files/Job-Multi-Project.yaml +36 -0
  42. data/spec/unit_tests/fixtures/files/project.yaml +15 -0
  43. data/spec/unit_tests/generator_spec.rb +67 -0
  44. data/spec/unit_tests/module_registry_spec.rb +19 -0
  45. data/spec/unit_tests/resolve_dependencies_spec.rb +230 -0
  46. data/spec/unit_tests/spec_helper.rb +29 -0
  47. metadata +75 -6
@@ -0,0 +1,14 @@
1
+ ---
2
+ - job:
3
+ name: Job-DSL1
4
+ job_type: job_dsl
5
+ job_dsl: |
6
+ job {
7
+ name 'DSL-Job'
8
+ }
9
+
10
+ - job:
11
+ name: Job-DSL2
12
+ job_type: job_dsl
13
+ job_dsl_targets: |
14
+ **/*.groovy
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.scm.NullSCM"/>
8
+ <canRoam>true</canRoam>
9
+ <disabled>false</disabled>
10
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
11
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
12
+ <triggers class="vector"/>
13
+ <concurrentBuild>false</concurrentBuild>
14
+ <builders>
15
+ <javaposse.jobdsl.plugin.ExecuteDslScripts>
16
+ <scriptText>job {
17
+ name 'DSL-Job'
18
+ }
19
+ </scriptText>
20
+ <usingScriptText>true</usingScriptText>
21
+ <ignoreExisting>false</ignoreExisting>
22
+ <removedJobAction>IGNORE</removedJobAction>
23
+ </javaposse.jobdsl.plugin.ExecuteDslScripts>
24
+ </builders>
25
+ <publishers/>
26
+ <buildWrappers/>
27
+ </project>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.scm.NullSCM"/>
8
+ <canRoam>true</canRoam>
9
+ <disabled>false</disabled>
10
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
11
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
12
+ <triggers class="vector"/>
13
+ <concurrentBuild>false</concurrentBuild>
14
+ <builders>
15
+ <javaposse.jobdsl.plugin.ExecuteDslScripts>
16
+ <targets>**/*.groovy
17
+ </targets>
18
+ <usingScriptText>false</usingScriptText>
19
+ <ignoreExisting>false</ignoreExisting>
20
+ <removedJobAction>IGNORE</removedJobAction>
21
+ </javaposse.jobdsl.plugin.ExecuteDslScripts>
22
+ </builders>
23
+ <publishers/>
24
+ <buildWrappers/>
25
+ </project>
@@ -0,0 +1,142 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties/>
7
+ <scm class="hudson.plugins.git.GitSCM">
8
+ <configVersion>2</configVersion>
9
+ <userRemoteConfigs>
10
+ <hudson.plugins.git.UserRemoteConfig>
11
+ <name/>
12
+ <refspec/>
13
+ <url>git@github.com:devops/repo.git</url>
14
+ </hudson.plugins.git.UserRemoteConfig>
15
+ </userRemoteConfigs>
16
+ <branches>
17
+ <hudson.plugins.git.BranchSpec>
18
+ <name>master</name>
19
+ </hudson.plugins.git.BranchSpec>
20
+ </branches>
21
+ <disableSubmodules>false</disableSubmodules>
22
+ <recursiveSubmodules>false</recursiveSubmodules>
23
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
24
+ <authorOrCommitter>false</authorOrCommitter>
25
+ <clean>false</clean>
26
+ <wipeOutWorkspace>false</wipeOutWorkspace>
27
+ <pruneBranches>false</pruneBranches>
28
+ <remotePoll>false</remotePoll>
29
+ <ignoreNotifyCommit>false</ignoreNotifyCommit>
30
+ <useShallowClone>false</useShallowClone>
31
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
32
+ <gitTool>Default</gitTool>
33
+ <submoduleCfg class="list"/>
34
+ <relativeTargetDir/>
35
+ <reference/>
36
+ <excludedRegions/>
37
+ <excludedUsers>user</excludedUsers>
38
+ <gitConfigName/>
39
+ <gitConfigEmail/>
40
+ <skipTag>false</skipTag>
41
+ <includedRegions/>
42
+ <scmName/>
43
+ </scm>
44
+ <canRoam>true</canRoam>
45
+ <disabled>false</disabled>
46
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
47
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
48
+ <triggers class="vector">
49
+ <hudson.triggers.SCMTrigger>
50
+ <spec>H/5 * * * *</spec>
51
+ <ignorePostCommitHooks>false</ignorePostCommitHooks>
52
+ </hudson.triggers.SCMTrigger>
53
+ </triggers>
54
+ <concurrentBuild>false</concurrentBuild>
55
+ <builders>
56
+ <hudson.tasks.Shell>
57
+ <command>run.sh</command>
58
+ </hudson.tasks.Shell>
59
+ </builders>
60
+ <publishers>
61
+ <hudson.tasks.junit.JUnitResultArchiver>
62
+ <testResults>out/**/*.xml</testResults>
63
+ <keepLongStdio>false</keepLongStdio>
64
+ <testDataPublishers/>
65
+ </hudson.tasks.junit.JUnitResultArchiver>
66
+ <hudson.plugins.git.GitPublisher>
67
+ <configVersion>2</configVersion>
68
+ <pushMerge>true</pushMerge>
69
+ <pushOnlyIfSuccess>false</pushOnlyIfSuccess>
70
+ <branchesToPush>
71
+ <hudson.plugins.git.GitPublisher_-BranchToPush>
72
+ <targetRepoName>origin</targetRepoName>
73
+ <branchName>master</branchName>
74
+ </hudson.plugins.git.GitPublisher_-BranchToPush>
75
+ </branchesToPush>
76
+ </hudson.plugins.git.GitPublisher>
77
+ <hudson.plugins.rubyMetrics.rcov.RcovPublisher>
78
+ <reportDir>out/coverage/rcov</reportDir>
79
+ <targets>
80
+ <hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
81
+ <metric>TOTAL_COVERAGE</metric>
82
+ <healthy>80</healthy>
83
+ <unhealthy>0</unhealthy>
84
+ <unstable>0</unstable>
85
+ </hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
86
+ <hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
87
+ <metric>CODE_COVERAGE</metric>
88
+ <healthy>80</healthy>
89
+ <unhealthy>0</unhealthy>
90
+ <unstable>0</unstable>
91
+ </hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
92
+ </targets>
93
+ </hudson.plugins.rubyMetrics.rcov.RcovPublisher>
94
+ </publishers>
95
+ <buildWrappers>
96
+ <hudson.plugins.ansicolor.AnsiColorBuildWrapper>
97
+ <colorMapName>xterm</colorMapName>
98
+ </hudson.plugins.ansicolor.AnsiColorBuildWrapper>
99
+ <org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
100
+ <details>
101
+ <artifactoryUrl>https://artifactory.com/artifactory</artifactoryUrl>
102
+ <artifactoryName>key</artifactoryName>
103
+ <repositoryKey>gems-local</repositoryKey>
104
+ <snapshotsRepositoryKey>gems-local</snapshotsRepositoryKey>
105
+ </details>
106
+ <deployPattern>pkg/*.gem</deployPattern>
107
+ <resolvePattern/>
108
+ <matrixParams/>
109
+ <deployBuildInfo>true</deployBuildInfo>
110
+ <includeEnvVars>false</includeEnvVars>
111
+ <envVarsPatterns>
112
+ <includePatterns/>
113
+ <excludePatterns>*password*,*secret*</excludePatterns>
114
+ </envVarsPatterns>
115
+ <discardOldBuilds>false</discardOldBuilds>
116
+ <discardBuildArtifacts>true</discardBuildArtifacts>
117
+ </org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
118
+ <EnvInjectBuildWrapper>
119
+ <info>
120
+ <propertiesContent>VAR1 = value_1</propertiesContent>
121
+ <loadFilesFromMaster>false</loadFilesFromMaster>
122
+ </info>
123
+ </EnvInjectBuildWrapper>
124
+ <EnvInjectPasswordWrapper>
125
+ <injectGlobalPasswords>false</injectGlobalPasswords>
126
+ <passwordEntries>
127
+ <EnvInjectPasswordEntry>
128
+ <name>OS_PASSWORD</name>
129
+ <value>some_encrypted_password</value>
130
+ </EnvInjectPasswordEntry>
131
+ </passwordEntries>
132
+ </EnvInjectPasswordWrapper>
133
+ <ruby-proxy-object>
134
+ <ruby-object ruby-class="Jenkins::Plugin::Proxies::BuildWrapper" pluginid="rvm">
135
+ <object ruby-class="RvmWrapper" pluginid="rvm">
136
+ <impl pluginid="rvm" ruby-class="String">`cat .ruby-version`@`cat .ruby-gemset`</impl>
137
+ </object>
138
+ <pluginid pluginid="rvm" ruby-class="String">rvm</pluginid>
139
+ </ruby-object>
140
+ </ruby-proxy-object>
141
+ </buildWrappers>
142
+ </project>
@@ -0,0 +1,41 @@
1
+ - job:
2
+ name: 'Job-Gem-Build'
3
+ job_type: free_style
4
+ scm_provider: git
5
+ scm_url: git@github.com:devops/repo.git
6
+ scm_branch: master
7
+ scm_params:
8
+ excuded_users: user
9
+ shell_command: 'run.sh'
10
+ triggers:
11
+ - scm_polling: 'H/5 * * * *'
12
+ wrappers:
13
+ - ansicolor: true
14
+ - artifactory:
15
+ url: 'https://artifactory.com/artifactory'
16
+ artifactory-name: 'key'
17
+ target-repo: gems-local
18
+ publish: 'pkg/*.gem'
19
+ publish-build-info: true
20
+ - inject_env_var: >
21
+ VAR1 = value_1
22
+ - inject_passwords:
23
+ - name: OS_PASSWORD
24
+ value: some_encrypted_password
25
+ - rvm: "`cat .ruby-version`@`cat .ruby-gemset`"
26
+ publishers:
27
+ - junit_result:
28
+ test_results: 'out/**/*.xml'
29
+ - git:
30
+ push-merge: true
31
+ push-only-if-success: false
32
+ - coverage_result:
33
+ report_dir: out/coverage/rcov
34
+ total:
35
+ healthy: 80
36
+ unhealthy: 0
37
+ unstable: 0
38
+ code:
39
+ healthy: 80
40
+ unhealthy: 0
41
+ unstable: 0
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project>
3
+ <actions/>
4
+ <description>Do not edit this job through the web!</description>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties>
7
+ <hudson.model.ParametersDefinitionProperty>
8
+ <parameterDefinitions>
9
+ <hudson.model.StringParameterDefinition>
10
+ <name>param1</name>
11
+ <description>Some description</description>
12
+ <defaultValue></defaultValue>
13
+ </hudson.model.StringParameterDefinition>
14
+ </parameterDefinitions>
15
+ </hudson.model.ParametersDefinitionProperty>
16
+ </properties>
17
+ <scm class="hudson.scm.NullSCM"/>
18
+ <canRoam>true</canRoam>
19
+ <disabled>false</disabled>
20
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
21
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
22
+ <triggers class="vector"/>
23
+ <concurrentBuild>false</concurrentBuild>
24
+ <builders>
25
+ <hudson.tasks.Shell>
26
+ <command>run.sh
27
+ </command>
28
+ </hudson.tasks.Shell>
29
+ </builders>
30
+ <publishers/>
31
+ <buildWrappers/>
32
+ </project>
@@ -0,0 +1,8 @@
1
+ ---
2
+ - job-template:
3
+ name: Job-{{name}}-From-Template
4
+ description: '{{description}}'
5
+ parameters:
6
+ - name: param1
7
+ description: Some description
8
+ shell_command: '{{command}}'
@@ -0,0 +1,117 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <com.tikal.jenkins.plugins.multijob.MultiJobProject>
3
+ <actions/>
4
+ <description/>
5
+ <keepDependencies>false</keepDependencies>
6
+ <properties>
7
+ <hudson.model.ParametersDefinitionProperty>
8
+ <parameterDefinitions>
9
+ <hudson.model.StringParameterDefinition>
10
+ <name>Param1</name>
11
+ <description>The git branch to be used when building application</description>
12
+ <defaultValue>release</defaultValue>
13
+ </hudson.model.StringParameterDefinition>
14
+ </parameterDefinitions>
15
+ </hudson.model.ParametersDefinitionProperty>
16
+ </properties>
17
+ <scm class="hudson.plugins.git.GitSCM">
18
+ <configVersion>2</configVersion>
19
+ <userRemoteConfigs>
20
+ <hudson.plugins.git.UserRemoteConfig>
21
+ <name/>
22
+ <refspec/>
23
+ <url>git@github:org/repo</url>
24
+ </hudson.plugins.git.UserRemoteConfig>
25
+ </userRemoteConfigs>
26
+ <branches>
27
+ <hudson.plugins.git.BranchSpec>
28
+ <name>release</name>
29
+ </hudson.plugins.git.BranchSpec>
30
+ </branches>
31
+ <disableSubmodules>false</disableSubmodules>
32
+ <recursiveSubmodules>true</recursiveSubmodules>
33
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
34
+ <authorOrCommitter>false</authorOrCommitter>
35
+ <clean>false</clean>
36
+ <wipeOutWorkspace>true</wipeOutWorkspace>
37
+ <pruneBranches>false</pruneBranches>
38
+ <remotePoll>false</remotePoll>
39
+ <ignoreNotifyCommit>false</ignoreNotifyCommit>
40
+ <useShallowClone>false</useShallowClone>
41
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
42
+ <gitTool>Default</gitTool>
43
+ <submoduleCfg class="list"/>
44
+ <relativeTargetDir/>
45
+ <reference/>
46
+ <excludedRegions/>
47
+ <excludedUsers>user</excludedUsers>
48
+ <gitConfigName/>
49
+ <gitConfigEmail/>
50
+ <skipTag>false</skipTag>
51
+ <includedRegions/>
52
+ <scmName/>
53
+ <localBranch>${GIT_BRANCH}</localBranch>
54
+ </scm>
55
+ <canRoam>true</canRoam>
56
+ <disabled>false</disabled>
57
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
58
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
59
+ <triggers class="vector">
60
+ <com.cloudbees.jenkins.GitHubPushTrigger>
61
+ <spec/>
62
+ </com.cloudbees.jenkins.GitHubPushTrigger>
63
+ <hudson.triggers.SCMTrigger>
64
+ <spec>H/5 * * * *</spec>
65
+ <ignorePostCommitHooks>false</ignorePostCommitHooks>
66
+ </hudson.triggers.SCMTrigger>
67
+ </triggers>
68
+ <concurrentBuild>false</concurrentBuild>
69
+ <builders>
70
+ <com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
71
+ <phaseName>Child Jobs</phaseName>
72
+ <phaseJobs>
73
+ <com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
74
+ <jobName>Child-Job</jobName>
75
+ <currParams>false</currParams>
76
+ <exposedSCM>false</exposedSCM>
77
+ <configs>
78
+ <hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
79
+ <properties>PARENT_WORKSPACE=${WORKSPACE}</properties>
80
+ </hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
81
+ </configs>
82
+ </com.tikal.jenkins.plugins.multijob.PhaseJobsConfig>
83
+ </phaseJobs>
84
+ <continuationCondition>SUCCESSFUL</continuationCondition>
85
+ </com.tikal.jenkins.plugins.multijob.MultiJobBuilder>
86
+ <EnvInjectBuilder>
87
+ <info>
88
+ <propertiesFilePath>build_job_info</propertiesFilePath>
89
+ </info>
90
+ </EnvInjectBuilder>
91
+ </builders>
92
+ <publishers>
93
+ <hudson.plugins.parameterizedtrigger.BuildTrigger>
94
+ <configs>
95
+ <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
96
+ <configs>
97
+ <hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
98
+ <properties>PARAM1=value1
99
+ PARAM2=value2
100
+ </properties>
101
+ </hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
102
+ <hudson.plugins.parameterizedtrigger.FileBuildParameters>
103
+ <propertiesFile>promote-job-params</propertiesFile>
104
+ <failTriggerOnMissing>false</failTriggerOnMissing>
105
+ </hudson.plugins.parameterizedtrigger.FileBuildParameters>
106
+ </configs>
107
+ <projects>Downstream-Job</projects>
108
+ <condition>SUCCESS</condition>
109
+ <triggerWithNoParameters>false</triggerWithNoParameters>
110
+ </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
111
+ </configs>
112
+ </hudson.plugins.parameterizedtrigger.BuildTrigger>
113
+ </publishers>
114
+ <buildWrappers>
115
+ <hudson.plugins.timestamper.TimestamperBuildWrapper/>
116
+ </buildWrappers>
117
+ </com.tikal.jenkins.plugins.multijob.MultiJobProject>
@@ -0,0 +1,36 @@
1
+ ---
2
+ - job:
3
+ name: Job-Multi-Project
4
+ job_type: multi_project
5
+ parameters:
6
+ - name: Param1
7
+ type: string
8
+ default: release
9
+ description: The git branch to be used when building application
10
+ scm_provider: git
11
+ scm_url: git@github:org/repo
12
+ scm_branch: release
13
+ scm_params:
14
+ local_branch: ${GIT_BRANCH}
15
+ recursive_update: true
16
+ wipe_workspace: true
17
+ excuded_users: user
18
+ triggers:
19
+ - git_push: true
20
+ - scm_polling: "H/5 * * * *"
21
+ builders:
22
+ - job_builder:
23
+ child_jobs:
24
+ - Child-Job
25
+ mark_phase: SUCCESSFUL
26
+ - inject_vars_file: build_job_info
27
+ publishers:
28
+ - downstream:
29
+ project: Downstream-Job
30
+ data:
31
+ - params: |
32
+ PARAM1=value1
33
+ PARAM2=value2
34
+ - file: promote-job-params
35
+ wrappers:
36
+ - timestamp: true