packaging 0.99.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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +17 -0
  3. data/README-Solaris.md +117 -0
  4. data/README.md +1031 -0
  5. data/lib/packaging.rb +32 -0
  6. data/lib/packaging/artifactory.rb +278 -0
  7. data/lib/packaging/config.rb +392 -0
  8. data/lib/packaging/config/params.rb +366 -0
  9. data/lib/packaging/deb.rb +28 -0
  10. data/lib/packaging/deb/repo.rb +263 -0
  11. data/lib/packaging/gem.rb +112 -0
  12. data/lib/packaging/ips.rb +57 -0
  13. data/lib/packaging/msi.rb +89 -0
  14. data/lib/packaging/nuget.rb +39 -0
  15. data/lib/packaging/osx.rb +36 -0
  16. data/lib/packaging/paths.rb +238 -0
  17. data/lib/packaging/platforms.rb +480 -0
  18. data/lib/packaging/repo.rb +55 -0
  19. data/lib/packaging/retrieve.rb +46 -0
  20. data/lib/packaging/rpm.rb +5 -0
  21. data/lib/packaging/rpm/repo.rb +257 -0
  22. data/lib/packaging/tar.rb +154 -0
  23. data/lib/packaging/util.rb +146 -0
  24. data/lib/packaging/util/date.rb +15 -0
  25. data/lib/packaging/util/execution.rb +85 -0
  26. data/lib/packaging/util/file.rb +125 -0
  27. data/lib/packaging/util/git.rb +174 -0
  28. data/lib/packaging/util/git_tags.rb +73 -0
  29. data/lib/packaging/util/gpg.rb +62 -0
  30. data/lib/packaging/util/jenkins.rb +95 -0
  31. data/lib/packaging/util/misc.rb +69 -0
  32. data/lib/packaging/util/net.rb +368 -0
  33. data/lib/packaging/util/os.rb +17 -0
  34. data/lib/packaging/util/platform.rb +40 -0
  35. data/lib/packaging/util/rake_utils.rb +111 -0
  36. data/lib/packaging/util/serialization.rb +19 -0
  37. data/lib/packaging/util/ship.rb +171 -0
  38. data/lib/packaging/util/tool.rb +41 -0
  39. data/lib/packaging/util/version.rb +326 -0
  40. data/spec/fixtures/config/ext/build_defaults.yaml +2 -0
  41. data/spec/fixtures/config/ext/project_data.yaml +2 -0
  42. data/spec/fixtures/config/params.yaml +2 -0
  43. data/spec/fixtures/configs/components/test_file.json +1 -0
  44. data/spec/fixtures/configs/components/test_file_2.json +0 -0
  45. data/spec/fixtures/configs/components/test_file_not_tagged.json +1 -0
  46. data/spec/fixtures/configs/components/test_file_wrong_ext.txt +0 -0
  47. data/spec/fixtures/configs/components/test_file_wrong_ext.wrong +0 -0
  48. data/spec/fixtures/util/pre_tasks.yaml +4 -0
  49. data/spec/lib/packaging/artifactory_spec.rb +171 -0
  50. data/spec/lib/packaging/config_spec.rb +556 -0
  51. data/spec/lib/packaging/deb/repo_spec.rb +148 -0
  52. data/spec/lib/packaging/deb_spec.rb +52 -0
  53. data/spec/lib/packaging/paths_spec.rb +153 -0
  54. data/spec/lib/packaging/platforms_spec.rb +153 -0
  55. data/spec/lib/packaging/repo_spec.rb +97 -0
  56. data/spec/lib/packaging/retrieve_spec.rb +61 -0
  57. data/spec/lib/packaging/rpm/repo_spec.rb +133 -0
  58. data/spec/lib/packaging/tar_spec.rb +122 -0
  59. data/spec/lib/packaging/util/execution_spec.rb +56 -0
  60. data/spec/lib/packaging/util/file_spec.rb +139 -0
  61. data/spec/lib/packaging/util/git_spec.rb +160 -0
  62. data/spec/lib/packaging/util/git_tag_spec.rb +36 -0
  63. data/spec/lib/packaging/util/gpg_spec.rb +64 -0
  64. data/spec/lib/packaging/util/jenkins_spec.rb +112 -0
  65. data/spec/lib/packaging/util/misc_spec.rb +31 -0
  66. data/spec/lib/packaging/util/net_spec.rb +239 -0
  67. data/spec/lib/packaging/util/os_spec.rb +31 -0
  68. data/spec/lib/packaging/util/rake_utils_spec.rb +70 -0
  69. data/spec/lib/packaging/util/ship_spec.rb +117 -0
  70. data/spec/lib/packaging/util/version_spec.rb +123 -0
  71. data/spec/lib/packaging_spec.rb +19 -0
  72. data/spec/spec_helper.rb +36 -0
  73. data/static_artifacts/PackageInfo.plist +3 -0
  74. data/tasks/00_utils.rake +216 -0
  75. data/tasks/30_metrics.rake +33 -0
  76. data/tasks/apple.rake +266 -0
  77. data/tasks/build.rake +12 -0
  78. data/tasks/clean.rake +5 -0
  79. data/tasks/config.rake +30 -0
  80. data/tasks/deb.rake +129 -0
  81. data/tasks/deb_repos.rake +28 -0
  82. data/tasks/deprecated.rake +130 -0
  83. data/tasks/doc.rake +20 -0
  84. data/tasks/education.rake +57 -0
  85. data/tasks/fetch.rake +57 -0
  86. data/tasks/gem.rake +146 -0
  87. data/tasks/jenkins.rake +494 -0
  88. data/tasks/jenkins_dynamic.rake +202 -0
  89. data/tasks/load_extras.rake +21 -0
  90. data/tasks/mock.rake +348 -0
  91. data/tasks/nightly_repos.rake +335 -0
  92. data/tasks/pe_deb.rake +12 -0
  93. data/tasks/pe_rpm.rake +13 -0
  94. data/tasks/pe_ship.rake +221 -0
  95. data/tasks/pe_sign.rake +13 -0
  96. data/tasks/pe_tar.rake +5 -0
  97. data/tasks/retrieve.rake +45 -0
  98. data/tasks/rpm.rake +66 -0
  99. data/tasks/rpm_repos.rake +29 -0
  100. data/tasks/ship.rake +752 -0
  101. data/tasks/sign.rake +226 -0
  102. data/tasks/tag.rake +8 -0
  103. data/tasks/tar.rake +34 -0
  104. data/tasks/update.rake +16 -0
  105. data/tasks/vanagon.rake +35 -0
  106. data/tasks/vendor_gems.rake +117 -0
  107. data/tasks/version.rake +33 -0
  108. data/tasks/z_data_dump.rake +65 -0
  109. data/templates/README +1 -0
  110. data/templates/downstream.xml.erb +47 -0
  111. data/templates/msi.xml.erb +197 -0
  112. data/templates/packaging.xml.erb +344 -0
  113. data/templates/repo.xml.erb +114 -0
  114. metadata +234 -0
@@ -0,0 +1,65 @@
1
+ ##
2
+ # These tasks are just wrappers for the build objects capabilities, exposed
3
+ # for our debugging purposes. This file is prepended with `z_` to ensure it is
4
+ # loaded last, so that any variable manipulations that occur in the rake tasks
5
+ # happen prior to printing (although ideally all variables have been set after
6
+ # loading `20_setupextrasvars.rake`).
7
+ #
8
+ namespace :pl do
9
+ ##
10
+ # Utility rake task that will dump all current build parameters and variables
11
+ # to a yaml file to a temporary location and print the path. Given the
12
+ # environment variable 'OUTPUT_DIR', output file at 'OUTPUT_DIR'. The
13
+ # environment variable TASK sets the task instance variable of the build to the
14
+ # supplied args, allowing us to use this file for later builds.
15
+ #
16
+ desc "Write all package build parameters to a yaml file, pass OUTPUT_DIR to specify outut location"
17
+ task :write_build_params do
18
+ if ENV['TASK']
19
+ task_args = ENV['TASK'].split(' ')
20
+ Pkg::Config.task = { :task => task_args[0], :args => task_args[1..-1] }
21
+ end
22
+ Pkg::Config.config_to_yaml(ENV['OUTPUT_DIR'])
23
+ end
24
+
25
+ ##
26
+ # Print all build parameters to $stdout.
27
+ #
28
+ desc "Print all package build parameters"
29
+ task :print_build_params do
30
+ Pkg::Config.print_config
31
+ end
32
+
33
+ ##
34
+ # Print a parameter passed as an argument to $stdout.
35
+ desc "Print a build parameter"
36
+ task :print_build_param, :param do |t, args|
37
+ # We want a string that is the from "@<param name>"
38
+ if param = args.param
39
+ getter = param.dup
40
+ if param[0] == ':'
41
+ getter = param[1..-1]
42
+ param[0] = "@"
43
+ elsif param[0] == "@"
44
+ getter = param[1..-1]
45
+ else
46
+ param.insert(0, "@")
47
+ end
48
+
49
+ # We want to fail if the param passed is bogus, print 'nil' if its not
50
+ # set, and print the value if its set.
51
+ if Pkg::Config.respond_to?(getter)
52
+ if val = Pkg::Config.instance_variable_get(param)
53
+ puts val
54
+ else
55
+ puts 'nil'
56
+ end
57
+ else
58
+ fail "Could not locate a build parameter called #{param}. For a list of available parameters, do `rake pl:print_build_params`"
59
+ end
60
+ else
61
+ fail "To print a build parameter, pass the param name as a rake argument. Ex: rake pl:print_build_param[:version]"
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1 @@
1
+ Add erb templates to this directory that packaging repo uses
@@ -0,0 +1,47 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <project>
3
+ <actions/>
4
+ <description>&lt;p&gt;&#xd;
5
+ When DOWNSTREAM_JOB is passed to the packaging repo, this job is created to wrap the call to that job.&#xd;
6
+ This allows us to use jenkins&apos; upstream/downstream chaining facilities while retaining the ability to trigger jobs on other jenkins hosts&#xd;
7
+ &lt;/p&gt;</description>
8
+ <keepDependencies>false</keepDependencies>
9
+ <properties>
10
+ <jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty plugin="hipchat-plugin@0.1.0">
11
+ <room></room>
12
+ <startNotification>false</startNotification>
13
+ </jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
14
+ </properties>
15
+ <scm class="hudson.scm.NullSCM"/>
16
+ <assignedNode>downstream</assignedNode>
17
+ <canRoam>false</canRoam>
18
+ <disabled>false</disabled>
19
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
20
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
21
+ <triggers class="vector"/>
22
+ <concurrentBuild>false</concurrentBuild>
23
+ <builders>
24
+ <hudson.tasks.Shell>
25
+ <command>#!/bin/bash
26
+ ## We have to check if this has been triggered by a successful package and repo build
27
+ curl -s &quot;http://<%= "#{Pkg::Config.jenkins_build_host}" %>/job/<%= "#{Pkg::Config.project}-repo-#{Pkg::Config.build_date}-#{Pkg::Config.ref}" %>/lastBuild/api/json&quot; | grep result\&quot;:\&quot;SUCCESS\&quot; &gt; /dev/null
28
+
29
+ UPSTREAM_BUILD_STATUS=$?
30
+
31
+ set -e
32
+
33
+ if [ $UPSTREAM_BUILD_STATUS -eq 0 ] ; then
34
+ UPSTREAM_BUILD_STATUS=&quot;success&quot;
35
+ else
36
+ UPSTREAM_BUILD_STATUS=&quot;failure&quot;
37
+ fi
38
+
39
+ # This URI was passed in as an argument to the original rake package call
40
+ curl -v --fail -i &quot;<%= Pkg::Util::Net.escape_html(Pkg::Util::Net.add_param_to_uri(add_param_to_uri(ENV['DOWNSTREAM_JOB'], "PACKAGE_BUILD_STATUS=$UPSTREAM_BUILD_STATUS"), "PACKAGE_BUILD_URL=#{ENV["PACKAGE_BUILD_URL"]}")) %>&quot;</command>
41
+ </hudson.tasks.Shell>
42
+ </builders>
43
+ <publishers/>
44
+ <buildWrappers>
45
+ <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="timestamper@1.8.4"/>
46
+ </buildWrappers>
47
+ </project>
@@ -0,0 +1,197 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <matrix-project>
3
+ <actions/>
4
+ <description>&lt;p&gt;&#xd;
5
+ Dynamically created job to generate the MSI for this version of Puppet&#xd;
6
+ &#xd;
7
+ The artifacts are sent out to builds.delivery.puppetlabs.net
8
+ &lt;p&gt;&#xd;
9
+ This job will trigger the downstream job supplied with DOWNSTREAM_JOB if passed to rake in the upstream invocation.&#xd;
10
+ &lt;/p&gt;&#xd;
11
+ </description>
12
+ <logRotator class="hudson.tasks.LogRotator">
13
+ <daysToKeep>3</daysToKeep>
14
+ <numToKeep>1</numToKeep>
15
+ <artifactDaysToKeep>-1</artifactDaysToKeep>
16
+ <artifactNumToKeep>-1</artifactNumToKeep>
17
+ </logRotator>
18
+ <keepDependencies>false</keepDependencies>
19
+ <properties>
20
+ <jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty plugin="hipchat-plugin@0.1.0">
21
+ <room></room>
22
+ <startNotification>false</startNotification>
23
+ </jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
24
+ </properties>
25
+ <scm class="hudson.plugins.git.GitSCM" plugin="git@1.2.0">
26
+ <configVersion>2</configVersion>
27
+ <userRemoteConfigs>
28
+ <hudson.plugins.git.UserRemoteConfig>
29
+ <name>origin</name>
30
+ <refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
31
+ <url><%= Pkg::Config.build_msi["puppet_for_the_win"]["repo"] %></url>
32
+ </hudson.plugins.git.UserRemoteConfig>
33
+ </userRemoteConfigs>
34
+ <branches>
35
+ <hudson.plugins.git.BranchSpec>
36
+ <name><%= Pkg::Config.build_msi["puppet_for_the_win"]["ref"] %></name>
37
+ </hudson.plugins.git.BranchSpec>
38
+ </branches>
39
+ <disableSubmodules>false</disableSubmodules>
40
+ <recursiveSubmodules>false</recursiveSubmodules>
41
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
42
+ <authorOrCommitter>false</authorOrCommitter>
43
+ <clean>false</clean>
44
+ <wipeOutWorkspace>false</wipeOutWorkspace>
45
+ <pruneBranches>false</pruneBranches>
46
+ <remotePoll>false</remotePoll>
47
+ <ignoreNotifyCommit>false</ignoreNotifyCommit>
48
+ <useShallowClone>false</useShallowClone>
49
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
50
+ <gitTool>Default</gitTool>
51
+ <submoduleCfg class="list"/>
52
+ <relativeTargetDir></relativeTargetDir>
53
+ <reference></reference>
54
+ <excludedRegions></excludedRegions>
55
+ <excludedUsers></excludedUsers>
56
+ <gitConfigName></gitConfigName>
57
+ <gitConfigEmail></gitConfigEmail>
58
+ <skipTag>true</skipTag>
59
+ <includedRegions></includedRegions>
60
+ <scmName></scmName>
61
+ </scm>
62
+ <assignedNode>win-build</assignedNode>
63
+ <canRoam>false</canRoam>
64
+ <disabled>false</disabled>
65
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
66
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
67
+ <triggers/>
68
+ <concurrentBuild>false</concurrentBuild>
69
+ <axes>
70
+ <hudson.matrix.TextAxis>
71
+ <name>ARCH</name>
72
+ <values>
73
+ <string>x64</string>
74
+ <string>x86</string>
75
+ </values>
76
+ </hudson.matrix.TextAxis>
77
+ <hudson.matrix.LabelAxis>
78
+ <name>label</name>
79
+ <values>
80
+ <string>win-build</string>
81
+ </values>
82
+ </hudson.matrix.LabelAxis>
83
+ </axes>
84
+ <builders>
85
+ <hudson.tasks.Shell>
86
+ <command>#!ruby.exe
87
+
88
+ require &apos;yaml&apos;
89
+
90
+ puts &quot;arch is #{ENV[&apos;ARCH&apos;]}&quot;
91
+
92
+ if ENV[&apos;ARCH&apos;] == &quot;x64&quot;
93
+ SYS_REF=&apos;<%= Pkg::Config.build_msi["sys"]["ref"]["x64"] %>&apos;
94
+ <% if Pkg::Config.build_msi["cfacter"] -%>
95
+ CFACTER=&apos;<%= Pkg::Config.build_msi["cfacter"]["archive"]["x64"] %>&apos;
96
+ <% end -%>
97
+ else
98
+ SYS_REF=&apos;<%= Pkg::Config.build_msi["sys"]["ref"]["x86"] %>&apos;
99
+ <% if Pkg::Config.build_msi["cfacter"] -%>
100
+ CFACTER=&apos;<%= Pkg::Config.build_msi["cfacter"]["archive"]["x86"] %>&apos;
101
+ <% end -%>
102
+ end
103
+
104
+ CONFIG = {
105
+ :repos =&gt; {
106
+ &apos;puppet&apos; =&gt; {
107
+ :ref =&gt; &apos;<%= ref %>&apos;,
108
+ :repo =&gt; &quot;#{ENV[&apos;WORKSPACE&apos;]}/puppet-<%= Pkg::Config.version %>-signing_bundle&quot;
109
+ },
110
+ <% Pkg::Config.build_msi.each do |project, info| -%>
111
+ <% next if project == "puppet_for_the_win" || project == "cfacter" -%>
112
+ &apos;<%= project %>&apos; =&gt; {
113
+ :ref =&gt; &quot;<%= ('#{SYS_REF}' if project == "sys") || info["ref"] %>&quot;,
114
+ :repo =&gt; &apos;<%= info["repo"] %>&apos;
115
+ },
116
+ <% end -%>
117
+ <% if Pkg::Config.build_msi["cfacter"] -%>
118
+ &apos;cfacter&apos; =&gt; {
119
+ :archive =&gt; &quot;#{CFACTER}&quot;,
120
+ :path =&gt; &apos;<%= Pkg::Config.build_msi["cfacter"]["path"] %>&apos;
121
+ },
122
+ <% end -%>
123
+ }
124
+ }
125
+
126
+ File.open(&quot;#{ENV[&apos;WORKSPACE&apos;]}/ondemand.yaml&quot;, &apos;w&apos;) { |f| f.write(YAML.dump(CONFIG)) }</command>
127
+ </hudson.tasks.Shell>
128
+ <hudson.tasks.BatchFile>
129
+ <command>
130
+ REM Print the environment
131
+ set
132
+
133
+ set PKG_NAME=<%= Pkg::Config.msi_name || 'puppet' %>
134
+ set AGENT_VERSION_STRING=<%= Pkg::Config.version %>
135
+ set ARCH=%ARCH%
136
+ set SUFFIX=-%ARCH%
137
+ if &quot;%ARCH%&quot; == &quot;x86&quot; (
138
+ set SUFFIX=
139
+ )
140
+
141
+ echo %CD%
142
+ set ORIG_PATH=/opt/jenkins-builds/puppet/<%= Pkg::Config.ref %>/artifacts
143
+ set GIT_BUNDLE=puppet-<%= Pkg::Config.version %>-signing_bundle.tar.gz
144
+ set BUILD_HOST=jenkins@builds.delivery.puppetlabs.net
145
+ scp %BUILD_HOST%:%ORIG_PATH%/%GIT_BUNDLE% .
146
+ tar xf %GIT_BUNDLE%
147
+
148
+ cmd.exe /c rake clobber windows:build config=ondemand.yaml
149
+
150
+ pushd pkg
151
+
152
+ REM If we are shipping the old version of puppet, in the 3.x series, we need to maintain established naming conventions.
153
+ REM For 3, we ship two msi's, one with a `-x64` suffix, and one with no architecture suffix at all. In order to
154
+ REM maintain that convention, we need to change the name of the installer we are shipping, either from puppet-x64.msi to puppet-%version%-x64.msi,
155
+ REM or from puppet.msi to puppet-%version%.msi. However, for windows installers in the puppet 4 series, we don't want to change the name at all,
156
+ REM which will already be set at puppet-agent-%version%-%arch%.msi
157
+ REM We also have to do this in multiple checks, because %MSI_NAME% is not updated until after the check ends...
158
+ set MSI_NAME=%PKG_NAME%-%AGENT_VERSION_STRING%-%ARCH%.msi
159
+ if exist %PKG_NAME%%SUFFIX%.msi (
160
+ set MSI_NAME=%PKG_NAME%-%AGENT_VERSION_STRING%%SUFFIX%.msi
161
+ )
162
+ if exist %PKG_NAME%%SUFFIX%.msi (
163
+ move %PKG_NAME%%SUFFIX%.msi %MSI_NAME%
164
+ )
165
+
166
+ set DEST_PATH=%ORIG_PATH%/windows
167
+ ssh %BUILD_HOST% &quot;mkdir -p %DEST_PATH%&quot;
168
+ REM rsync -avg --ignore-existing %MSI_NAME% %BUILD_HOST%:%DEST_PATH%
169
+ scp -B %MSI_NAME% %BUILD_HOST%:%DEST_PATH%
170
+
171
+ echo Puppet&apos;s package name is: %PKG_NAME%
172
+ echo Puppet&apos;s version is: %AGENT_VERSION_STRING%
173
+ echo Puppet&apos;s arch is: %ARCH%
174
+ echo Find the msi at: http://builds.delivery.puppetlabs.net/puppet/<%= Pkg::Config.ref %>/artifacts/windows/%MSI_NAME%
175
+
176
+ popd</command>
177
+ </hudson.tasks.BatchFile>
178
+ </builders>
179
+ <publishers>
180
+ <hudson.plugins.parameterizedtrigger.BuildTrigger plugin="parameterized-trigger@2.16">
181
+ <configs>
182
+ <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
183
+ <configs>
184
+ <hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>
185
+ </configs>
186
+ <projects><%= "#{Pkg::Config.project}-repo-#{Pkg::Config.build_date}-#{Pkg::Config.ref}" %></projects>
187
+ <condition>ALWAYS</condition>
188
+ <triggerWithNoParameters>false</triggerWithNoParameters>
189
+ </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
190
+ </configs>
191
+ </hudson.plugins.parameterizedtrigger.BuildTrigger>
192
+ </publishers>
193
+ <buildWrappers/>
194
+ <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
195
+ <runSequentially>false</runSequentially>
196
+ </executionStrategy>
197
+ </matrix-project>
@@ -0,0 +1,344 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <matrix-project>
3
+ <actions/>
4
+ <description>&lt;p&gt;&#xd;
5
+ Dynamically Created Packaging Job for a packaging repo-compatible project.&#xd;
6
+ Intended to be triggered from within a project with the packaging repo&#xd;
7
+ bootstrapped.&#xd;
8
+ &lt;/p&gt;&#xd;
9
+ &lt;p&gt;&#xd;
10
+ Three parameters are expected:&#xd;
11
+ &lt;/p&gt;&#xd;
12
+ 1) File: A build parameters file that describes information about the build state&#xd;
13
+ &lt;br&gt;&#xd;
14
+ 2) File: A tar.gz of a git bundle, created by the packaging repo, of the&#xd;
15
+ current state of the project to be packaged&#xd;
16
+ &lt;/br&gt;&#xd;
17
+ &lt;br&gt;&#xd;
18
+ 3) String: The project, e.g. facter, puppet&#xd;
19
+ &lt;/br&gt;&#xd;
20
+ &lt;p&gt;&#xd;
21
+ This job will be triggered automatically after generation by the packaging&#xd;
22
+ repo.&#xd;
23
+ &lt;/p&gt;&#xd;
24
+ &lt;br&gt;&#xd;
25
+ To trigger another downstream job after completion of this and the downstream repo creation job, pass DOWNSTREAM_JOB=$URI with the invocation, e.g.&#xd;
26
+ &lt;/br&gt;&#xd;
27
+ &lt;p&gt;&#xd;
28
+ pl:jenkins:uber_build DOWNSTREAM_JOB=http://jenkins-release.delivery.puppetlabs.net/job/puppetlabs-packaging-downstream-test/build&#xd;
29
+ &lt;/p&gt;&#xd;
30
+ &lt;p&gt;&#xd;
31
+ To get notified of the failure of this packaging job, pass NOTIFY= with the invocation, e.g.&#xd;
32
+ &lt;/p&gt;&#xd;
33
+ &lt;p&gt;&#xd;
34
+ pl:jenkins:uber_build NOTIFY=foo@puppetlabs.com&#xd;
35
+ &lt;/p&gt;&#xd;
36
+ &lt;p&gt;&#xd;
37
+ Successful completion of packaging will result in the automatic creation of&#xd;
38
+ apt/yum repositories on the distribution server with the built packages. To&#xd;
39
+ generate client apt/yum repository config files for accessing these packages,&#xd;
40
+ check out the ref of the git sha that was packaged, and run `rake&#xd;
41
+ pl:jenkins:(deb|rpm)_repo_configs`. Configuration files will be generated and&#xd;
42
+ deposited locally in pkg/repo_configs.&#xd;
43
+ &lt;/p&gt;&#xd;
44
+ &#xd;
45
+ &#xd;
46
+ &#xd;
47
+ </description>
48
+ <logRotator class="hudson.tasks.LogRotator">
49
+ <daysToKeep>3</daysToKeep>
50
+ <numToKeep>-1</numToKeep>
51
+ <artifactDaysToKeep>-1</artifactDaysToKeep>
52
+ <artifactNumToKeep>-1</artifactNumToKeep>
53
+ </logRotator>
54
+ <keepDependencies>false</keepDependencies>
55
+ <properties>
56
+ <jp.ikedam.jenkins.plugins.groovy__label__assignment.GroovyLabelAssignmentProperty plugin="groovy-label-assignment@1.0.0">
57
+ <groovyScript>def labelMap = [
58
+ <% if Pkg::Config.cows %>
59
+ <% Pkg::Config.cows.split(' ').each do |cow| %>
60
+ <% if cow =~ /cumulus/ %>
61
+ &quot;pl_deb COW=<%= cow %>&quot;: &quot;cumulus&quot;,
62
+ <% else %>
63
+ &quot;pl_deb COW=<%= cow %>&quot;: &quot;deb&quot;,
64
+ <% end %>
65
+ <% end %>
66
+ <% end %>
67
+ <% if Pkg::Config.final_mocks %>
68
+ <% Pkg::Config.final_mocks.split(' ').each do |mock| %>&quot;pl_mock MOCK=<%= mock %>&quot;: &quot;rpm&quot;,<% end %>
69
+ <% end %>
70
+ <% if Pkg::Config.build_tar then %>&quot;package_tar&quot;: &quot;rpm&quot;,<% end %>
71
+ <% if Pkg::Config.build_gem then %>&quot;package_gem&quot;: &quot;gem&quot;,<% end %>
72
+ <% if Pkg::Config.build_dmg then %>&quot;package_apple&quot;: &quot;dmg&quot;,<% end %>
73
+ ];
74
+ return labelMap.get(binding.getVariables().get(&quot;command&quot;));</groovyScript>
75
+ </jp.ikedam.jenkins.plugins.groovy__label__assignment.GroovyLabelAssignmentProperty>
76
+ <jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty plugin="hipchat-plugin@0.1.0">
77
+ <room></room>
78
+ <startNotification>false</startNotification>
79
+ </jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
80
+ <hudson.model.ParametersDefinitionProperty>
81
+ <parameterDefinitions>
82
+ <hudson.model.FileParameterDefinition>
83
+ <name>BUILD_PROPERTIES</name>
84
+ <description></description>
85
+ </hudson.model.FileParameterDefinition>
86
+ <hudson.model.FileParameterDefinition>
87
+ <name>PROJECT_BUNDLE</name>
88
+ <description></description>
89
+ </hudson.model.FileParameterDefinition>
90
+ <hudson.model.StringParameterDefinition>
91
+ <name>PROJECT</name>
92
+ <description></description>
93
+ <defaultValue></defaultValue>
94
+ </hudson.model.StringParameterDefinition>
95
+ <hudson.model.StringParameterDefinition>
96
+ <name>METRICS</name>
97
+ <description></description>
98
+ <defaultValue></defaultValue>
99
+ </hudson.model.StringParameterDefinition>
100
+ </parameterDefinitions>
101
+ </hudson.model.ParametersDefinitionProperty>
102
+ </properties>
103
+ <scm class="hudson.scm.NullSCM"/>
104
+ <canRoam>true</canRoam>
105
+ <disabled>false</disabled>
106
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
107
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
108
+ <triggers class="vector"/>
109
+ <concurrentBuild>false</concurrentBuild>
110
+ <axes>
111
+ <hudson.matrix.TextAxis>
112
+ <name>command</name>
113
+ <values>
114
+ <% if Pkg::Config.cows %>
115
+ <% Pkg::Config.cows.split(' ').each do |cow| %><string>pl_deb COW=<%= cow %></string><% end %>
116
+ <% end %>
117
+ <% if Pkg::Config.final_mocks %>
118
+ <% Pkg::Config.final_mocks.split(' ').each do |mock| %><string>pl_mock MOCK=<%= mock %></string><% end %>
119
+ <% end %>
120
+ <% if Pkg::Config.build_tar then %><string>package_tar</string><% end %>
121
+ <% if Pkg::Config.build_gem then %><string>package_gem</string><% end %>
122
+ <% if Pkg::Config.build_dmg then %><string>package_apple</string><% end %>
123
+ </values>
124
+ </hudson.matrix.TextAxis>
125
+ </axes>
126
+ <builders>
127
+ <hudson.tasks.Shell>
128
+ <command>#!/bin/bash
129
+ set -e
130
+ ### Create a local clone of the git-bundle that was passed
131
+ # The bundle is wrapped in a tarball. We don't need to know the project that is
132
+ # in the git bundle.
133
+
134
+ # Swap out _ for : in the command - lein cannot handle : in paths, and jenkins
135
+ # automatically makes directories with the names of the matrix cell (in this
136
+ # case $command) if https://github.com/technomancy/leiningen/issues/891 is ever
137
+ # resolved, this dirty hack can be removed.
138
+ command=$(echo $command | sed 's/_/:/1')
139
+
140
+ [ -f &quot;PROJECT_BUNDLE&quot; ] || exit 1
141
+ mkdir project &amp;&amp; tar -xzf PROJECT_BUNDLE -C project/
142
+
143
+ pushd project
144
+ git clone --recursive $(ls) git_repo
145
+
146
+ pushd git_repo
147
+
148
+ ### Clone the packaging repo
149
+ rake package:bootstrap
150
+
151
+ ### Perform the build
152
+ rake $command PARAMS_FILE=&quot;$WORKSPACE/BUILD_PROPERTIES&quot; --trace
153
+
154
+ ### Send the results
155
+ rake pl:jenkins:ship[&quot;artifacts&quot;] PARAMS_FILE=&quot;$WORKSPACE/BUILD_PROPERTIES&quot; --trace
156
+
157
+ popd
158
+ popd</command>
159
+ </hudson.tasks.Shell>
160
+ </builders>
161
+ <publishers>
162
+ <org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder plugin="groovy-postbuild@1.8">
163
+ <groovyScript>
164
+ import java.util.regex.Matcher
165
+ import java.util.regex.Pattern
166
+ import java.net.HttpURLConnection
167
+ import java.util.Date;
168
+
169
+ def get_jenkins_build_time() {
170
+ start_time = manager.build.getStartTimeInMillis()
171
+ end_time = new Date().getTime()
172
+ return String.valueOf((end_time - start_time)/1000)
173
+ }
174
+
175
+ // Assemble metrics to post to build metrics server
176
+
177
+ app_server = &quot;<%= Pkg::Config.metrics_url %>&quot;
178
+ task_metrics = manager.build.getEnvironment(manager.listener)[&apos;METRICS&apos;]
179
+ charset = &quot;UTF-8&quot;
180
+
181
+ // Maintain backwards compatibility
182
+ if ( task_metrics == null) {
183
+ build_user = &quot;N/A&quot;
184
+ version = &quot;N/A&quot;
185
+ pe_version = &quot;N/A&quot;
186
+ build_team = &quot;N/A&quot;
187
+ } else {
188
+ build_user = task_metrics.split(&quot;~&quot;)[0]
189
+ version = task_metrics.split(&quot;~&quot;)[1]
190
+ pe_version = task_metrics.split(&quot;~&quot;)[2]
191
+ build_team = task_metrics.split(&quot;~&quot;)[3]
192
+ }
193
+
194
+ matcher = manager.getLogMatcher(/(?:Finished building in:) ([\d]+\.?[\d]*)/)
195
+ if (matcher != null) {
196
+ package_build_time = matcher[0][1]
197
+ } else {
198
+ package_build_time = &quot;N/A&quot;
199
+ }
200
+
201
+ cmd_string = manager.build.getEnvironment(manager.listener)[&apos;command&apos;]
202
+ if(cmd_string =~ /deb/) {
203
+ package_type = 'deb'
204
+ } else if(cmd_string =~ /rpm|mock/) {
205
+ package_type = 'rpm'
206
+ } else if(cmd_string =~ /gem/) {
207
+ package_type = 'gem'
208
+ } else if(cmd_string =~ /apple/) {
209
+ package_type = 'dmg'
210
+ } else if(cmd_string =~ /tar/) {
211
+ package_type = 'tar'
212
+ } else {
213
+ package_type = 'N/A'
214
+ }
215
+
216
+ switch (package_type) {
217
+ case 'deb':
218
+ dist = cmd_string.split('-')[1]
219
+ break
220
+ case 'rpm':
221
+ if(pe_version != 'N/A') {
222
+ dist = cmd_string.split('-')[2]
223
+ } else {
224
+ dist = cmd_string.split('-')[1] + cmd_string.split('-')[2]
225
+ }
226
+ break
227
+ case 'gem':
228
+ dist = 'gem'
229
+ break
230
+ case 'dmg':
231
+ dist = 'apple'
232
+ break
233
+ case 'tar':
234
+ dist = 'tar'
235
+ break
236
+ default:
237
+ dist = 'N/A'
238
+ }
239
+
240
+ jenkins_build_time = get_jenkins_build_time()
241
+ package_name = manager.build.getEnvironment(manager.listener)[&apos;PROJECT&apos;]
242
+ build_loc = manager.build.getEnvironment(manager.listener)[&apos;NODE_NAME&apos;]
243
+ build_log = &quot;${manager.build.getEnvironment(manager.listener)[&apos;BUILD_URL&apos;]}&quot; + &quot;consoleText&quot;
244
+ success = String.valueOf(manager.build.result)
245
+
246
+ String query = String.format(&quot;package_name=%s&amp;dist=%s&amp;package_type=%s&amp;build_user=%s&amp;build_team=%s&amp;build_loc=%s&amp;version=%s&amp;pe_version=%s&amp;success=%s&amp;build_log=%s&amp;jenkins_build_time=%s&amp;package_build_time=%s&quot;,
247
+ URLEncoder.encode(package_name, charset),
248
+ URLEncoder.encode(dist, charset),
249
+ URLEncoder.encode(package_type, charset),
250
+ URLEncoder.encode(build_user, charset),
251
+ URLEncoder.encode(build_team, charset),
252
+ URLEncoder.encode(build_loc, charset),
253
+ URLEncoder.encode(version, charset),
254
+ URLEncoder.encode(pe_version, charset),
255
+ URLEncoder.encode(success, charset),
256
+ URLEncoder.encode(build_log, charset),
257
+ URLEncoder.encode(jenkins_build_time, charset),
258
+ URLEncoder.encode(package_build_time, charset))
259
+
260
+ // Make sure the server is listening before attempting to post data
261
+
262
+ URLConnection connection = null
263
+ serverAlive = false
264
+ try {
265
+ URL u = new URL(app_server);
266
+ connection = (HttpURLConnection) u.openConnection();
267
+ connection.setRequestMethod(&quot;GET&quot;);
268
+ int code = connection.getResponseCode();
269
+ serverAlive = true
270
+ connection.disconnect();
271
+
272
+ } catch (MalformedURLException e) {
273
+ serverAlive = false
274
+ e.printStackTrace()
275
+
276
+ } catch (IOException e) {
277
+ serverAlive = false
278
+ e.printStackTrace()
279
+
280
+ } finally {
281
+ if (serverAlive == true) {
282
+ connection = new URL(app_server).openConnection()
283
+ connection.setDoOutput(true) // Triggers POST.
284
+ connection.setRequestProperty(&quot;Accept-Charset&quot;, charset);
285
+ connection.setRequestProperty(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded;charset=&quot; + charset);
286
+ OutputStream output = null;
287
+
288
+ try {
289
+ output = connection.getOutputStream()
290
+ output.write(query.getBytes(charset))
291
+ InputStream response = connection.getInputStream()
292
+ } finally {
293
+ if (output != null) try { output.close(); } catch (IOException logOrIgnore) {}
294
+ }
295
+ }
296
+ } </groovyScript>
297
+ <behavior>0</behavior>
298
+ </org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder>
299
+ <hudson.tasks.ArtifactArchiver>
300
+ <artifacts>**/PROJECT_BUNDLE, **/BUILD_PROPERTIES</artifacts>
301
+ <latestOnly>false</latestOnly>
302
+ <allowEmptyArchive>false</allowEmptyArchive>
303
+ </hudson.tasks.ArtifactArchiver><% if Pkg::Config.notify %>
304
+ <hudson.tasks.Mailer plugin="mailer@1.4">
305
+ <recipients><%= "#{Pkg::Config.notify}" %></recipients>
306
+ <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
307
+ <sendToIndividuals>false</sendToIndividuals>
308
+ </hudson.tasks.Mailer><% end %>
309
+ <hudson.plugins.parameterizedtrigger.BuildTrigger plugin="parameterized-trigger@2.16">
310
+ <configs>
311
+ <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
312
+ <configs>
313
+ <hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>
314
+ </configs>
315
+ <% if Pkg::Config.build_msi
316
+ downstream = "#{Pkg::Config.project}-msi-#{Pkg::Config.build_date}-#{Pkg::Config.short_ref}"
317
+ else
318
+ downstream = "#{Pkg::Config.project}-repo-#{Pkg::Config.build_date}-#{Pkg::Config.ref}"
319
+ end -%>
320
+ <projects><%= downstream %></projects>
321
+ <condition>ALWAYS</condition>
322
+ <triggerWithNoParameters>false</triggerWithNoParameters>
323
+ </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
324
+ </configs>
325
+ </hudson.plugins.parameterizedtrigger.BuildTrigger>
326
+ </publishers>
327
+ <buildWrappers>
328
+ <hudson.plugins.build__timeout.BuildTimeoutWrapper plugin="build-timeout@1.11">
329
+ <timeoutMinutes>90</timeoutMinutes>
330
+ <failBuild>false</failBuild>
331
+ <writingDescription>false</writingDescription>
332
+ <timeoutPercentage>0</timeoutPercentage>
333
+ <timeoutType>absolute</timeoutType>
334
+ <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
335
+ </hudson.plugins.build__timeout.BuildTimeoutWrapper>
336
+ <hudson.plugins.ansicolor.AnsiColorBuildWrapper plugin="ansicolor@0.3.1">
337
+ <colorMapName>xterm</colorMapName>
338
+ </hudson.plugins.ansicolor.AnsiColorBuildWrapper>
339
+ <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="timestamper@1.8.4"/>
340
+ </buildWrappers>
341
+ <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
342
+ <runSequentially>false</runSequentially>
343
+ </executionStrategy>
344
+ </matrix-project>