3e8223a6d4065ccf5f173d933bd4b116a4b9f0f0
[releng/global-jjb.git] / jjb-test / expected-xml / github-ciman-packer-verify
1 <?xml version="1.0" encoding="utf-8"?>
2 <project>
3   <actions/>
4   <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
5   <keepDependencies>false</keepDependencies>
6   <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
7   <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
8   <concurrentBuild>true</concurrentBuild>
9   <assignedNode>build-vm</assignedNode>
10   <canRoam>false</canRoam>
11   <properties>
12     <com.coravy.hudson.plugins.github.GithubProjectProperty>
13       <projectUrl>https://github.com/example-org/releng/ciman</projectUrl>
14     </com.coravy.hudson.plugins.github.GithubProjectProperty>
15     <hudson.model.ParametersDefinitionProperty>
16       <parameterDefinitions>
17         <hudson.model.StringParameterDefinition>
18           <name>PROJECT</name>
19           <description>Parameter to identify a Gerrit project. This is typically the
20 project repo path as exists in Gerrit.
21 For example: ofextensions/circuitsw
22 </description>
23           <defaultValue>releng/ciman</defaultValue>
24         </hudson.model.StringParameterDefinition>
25         <hudson.model.StringParameterDefinition>
26           <name>STREAM</name>
27           <description>Stream is often set to the same name as 'branch' but can
28 sometimes be used as a name representing a project's release code
29 name.
30 </description>
31           <defaultValue>master</defaultValue>
32         </hudson.model.StringParameterDefinition>
33         <hudson.model.StringParameterDefinition>
34           <name>GERRIT_PROJECT</name>
35           <description>Parameter to identify Gerrit project. This is typically the
36 project repo path as exists in Gerrit.
37 For example: ofextensions/circuitsw
38
39 Note that Gerrit will override this parameter automatically if a
40 job is triggered by Gerrit.
41 </description>
42           <defaultValue>releng/ciman</defaultValue>
43         </hudson.model.StringParameterDefinition>
44         <hudson.model.StringParameterDefinition>
45           <name>GERRIT_BRANCH</name>
46           <description>Parameter to identify a Gerrit branch.
47
48 Note that Gerrit will override this parameter automatically if a
49 job is triggered by Gerrit.
50 </description>
51           <defaultValue>master</defaultValue>
52         </hudson.model.StringParameterDefinition>
53         <hudson.model.StringParameterDefinition>
54           <name>GERRIT_REFSPEC</name>
55           <description>Parameter to identify a refspec when pulling from Gerrit.
56
57 Note that Gerrit will override this parameter automatically if a
58 job is triggered by Gerrit.
59 </description>
60           <defaultValue/>
61         </hudson.model.StringParameterDefinition>
62         <hudson.model.StringParameterDefinition>
63           <name>PACKER_VERSION</name>
64           <description>Packer version to download and install.</description>
65           <defaultValue>1.0.2</defaultValue>
66         </hudson.model.StringParameterDefinition>
67       </parameterDefinitions>
68     </hudson.model.ParametersDefinitionProperty>
69   </properties>
70   <scm class="hudson.plugins.git.GitSCM">
71     <configVersion>2</configVersion>
72     <userRemoteConfigs>
73       <hudson.plugins.git.UserRemoteConfig>
74         <name>origin</name>
75         <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
76         <url>git@github.com:example-org/releng/ciman</url>
77         <credentialsId>test-credential</credentialsId>
78       </hudson.plugins.git.UserRemoteConfig>
79     </userRemoteConfigs>
80     <branches>
81       <hudson.plugins.git.BranchSpec>
82         <name>**</name>
83       </hudson.plugins.git.BranchSpec>
84     </branches>
85     <excludedUsers/>
86     <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
87     <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
88     <authorOrCommitter>false</authorOrCommitter>
89     <wipeOutWorkspace>true</wipeOutWorkspace>
90     <pruneBranches>false</pruneBranches>
91     <remotePoll>false</remotePoll>
92     <gitTool>Default</gitTool>
93     <submoduleCfg class="list"/>
94     <relativeTargetDir/>
95     <reference/>
96     <gitConfigName/>
97     <gitConfigEmail/>
98     <skipTag>true</skipTag>
99     <scmName/>
100     <useShallowClone>false</useShallowClone>
101     <ignoreNotifyCommit>false</ignoreNotifyCommit>
102     <extensions>
103       <hudson.plugins.git.extensions.impl.SubmoduleOption>
104         <disableSubmodules>false</disableSubmodules>
105         <recursiveSubmodules>true</recursiveSubmodules>
106         <trackingSubmodules>false</trackingSubmodules>
107         <reference/>
108         <timeout>10</timeout>
109       </hudson.plugins.git.extensions.impl.SubmoduleOption>
110       <hudson.plugins.git.extensions.impl.WipeWorkspace/>
111     </extensions>
112   </scm>
113   <triggers class="vector">
114     <org.jenkinsci.plugins.ghprb.GhprbTrigger>
115       <spec/>
116       <adminlist/>
117       <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
118       <whitelist/>
119       <orgslist/>
120       <cron/>
121       <triggerPhrase>^recheck$</triggerPhrase>
122       <onlyTriggerPhrase>false</onlyTriggerPhrase>
123       <useGitHubHooks>true</useGitHubHooks>
124       <permitAll>true</permitAll>
125       <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
126       <extensions>
127         <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
128           <commitStatusContext>Packer Verify</commitStatusContext>
129         </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
130       </extensions>
131     </org.jenkinsci.plugins.ghprb.GhprbTrigger>
132   </triggers>
133   <builders>
134     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
135       <managedFiles>
136         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
137           <fileId>ci-packer-cloud-env</fileId>
138           <targetLocation/>
139           <variable>CLOUDENV</variable>
140         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
141       </managedFiles>
142     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
143     <EnvInjectBuilder>
144       <info>
145         <propertiesContent>PACKER_VERSION=1.0.2
146 </propertiesContent>
147       </info>
148     </EnvInjectBuilder>
149     <hudson.tasks.Shell>
150       <command>#!/bin/bash
151 # SPDX-License-Identifier: EPL-1.0
152 ##############################################################################
153 # Copyright (c) 2017 The Linux Foundation and others.
154 #
155 # All rights reserved. This program and the accompanying materials
156 # are made available under the terms of the Eclipse Public License v1.0
157 # which accompanies this distribution, and is available at
158 # http://www.eclipse.org/legal/epl-v10.html
159 ##############################################################################
160 echo &quot;---&gt; packer-install.sh&quot;
161 # The script checks for the packer binaries and installs the binary
162 # if its not available
163
164 # $PACKER_VERSION        : Define a packer version passed as job paramter
165
166 PACKER_VERSION=&quot;${PACKER_VERSION:-1.0.2}&quot;
167
168 # Ensure we fail the job if any steps fail.
169 set -eu -o pipefail
170 # Default packer binary made available on the build image
171 packer_bin=&quot;/usr/local/bin/packer.io&quot;
172
173 if hash &quot;$packer_bin&quot; 2&gt;/dev/null; then
174     echo &quot;packer.io command is available.&quot;
175 else
176     echo &quot;packer.io command not is available. Installing packer ...&quot;
177     # Installs Hashicorp's Packer binary, required for verify &amp; merge packer jobs
178     pushd packer
179     wget &quot;https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip&quot;
180     mkdir -p &quot;${WORKSPACE}/bin&quot;
181     unzip &quot;packer_${PACKER_VERSION}_linux_amd64.zip&quot; -d ${WORKSPACE}/bin/
182     # rename packer to avoid conflict with binary in cracklib
183     mv ${WORKSPACE}/bin/packer &quot;${WORKSPACE}/bin/packer.io&quot;
184     popd
185 fi
186
187 #!/bin/bash
188 # SPDX-License-Identifier: EPL-1.0
189 ##############################################################################
190 # Copyright (c) 2017 The Linux Foundation and others.
191 #
192 # All rights reserved. This program and the accompanying materials
193 # are made available under the terms of the Eclipse Public License v1.0
194 # which accompanies this distribution, and is available at
195 # http://www.eclipse.org/legal/epl-v10.html
196 ##############################################################################
197 echo &quot;---&gt; packer-validate.sh&quot;
198 # The script validates an packers files.
199
200 # $CLOUDENV            :  Provides the cloud credential file.
201
202 # Ensure we fail the job if any steps fail.
203 set -eu -o pipefail
204
205 PACKER_LOGS_DIR=&quot;$WORKSPACE/archives/packer&quot;
206 mkdir -p &quot;$PACKER_LOGS_DIR&quot;
207 export PATH=&quot;${WORKSPACE}/bin:$PATH&quot;
208
209 cd packer
210 varfiles=(../packer/vars/*.json)
211 templates=(../packer/templates/*.json)
212
213 for varfile in &quot;${varfiles[@]}&quot;; do
214     for template in &quot;${templates[@]}&quot;; do
215         export PACKER_LOG=&quot;yes&quot; &amp;&amp; \
216         export PACKER_LOG_PATH=&quot;$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log&quot; &amp;&amp; \
217                     packer.io validate -var-file=&quot;$CLOUDENV&quot; \
218                     -var-file=&quot;$varfile&quot; &quot;$template&quot;
219         if [ $? -ne 0 ]; then
220             break
221         fi
222     done
223 done
224 </command>
225     </hudson.tasks.Shell>
226     <hudson.tasks.Shell>
227       <command>#!/bin/bash
228 # SPDX-License-Identifier: EPL-1.0
229 ##############################################################################
230 # Copyright (c) 2017 The Linux Foundation and others.
231 #
232 # All rights reserved. This program and the accompanying materials
233 # are made available under the terms of the Eclipse Public License v1.0
234 # which accompanies this distribution, and is available at
235 # http://www.eclipse.org/legal/epl-v10.html
236 ##############################################################################
237 echo &quot;---&gt; packer-clear-credentials.sh&quot;
238
239 set +e  # DO NOT cause build failure if any of the rm calls fail.
240 rm &quot;$CLOUDENV&quot;
241 exit 0
242 </command>
243     </hudson.tasks.Shell>
244   </builders>
245   <publishers>
246     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
247       <buildSteps>
248         <hudson.tasks.Shell>
249           <command>#!/bin/bash
250 # SPDX-License-Identifier: EPL-1.0
251 ##############################################################################
252 # Copyright (c) 2017 The Linux Foundation and others.
253 #
254 # All rights reserved. This program and the accompanying materials
255 # are made available under the terms of the Eclipse Public License v1.0
256 # which accompanies this distribution, and is available at
257 # http://www.eclipse.org/legal/epl-v10.html
258 ##############################################################################
259 echo &quot;---&gt; sysstat.sh&quot;
260 set +e  # DON'T fail build if script fails.
261
262 OS=$(facter operatingsystem)
263 case &quot;$OS&quot; in
264     Ubuntu)
265         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
266
267         # Dont run the script when systat is not enabled by default
268         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
269             exit 0
270         fi
271     ;;
272     CentOS|RedHat)
273         SYSSTAT_PATH=&quot;/var/log/sa&quot;
274     ;;
275     *)
276         # nothing to do
277         exit 0
278     ;;
279 esac
280
281 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
282 mkdir -p &quot;$SAR_DIR&quot;
283 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
284 # convert sar data to ascii format
285 while IFS=&quot;&quot; read -r s
286 do
287     [ -f &quot;$s&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$s&quot; &gt; &quot;$SAR_DIR/sar${s//[!0-9]/}&quot;
288 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
289
290 # DON'T fail build if script fails.
291 exit 0
292 </command>
293         </hudson.tasks.Shell>
294         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
295           <managedFiles>
296             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
297               <fileId>jenkins-log-archives-settings</fileId>
298               <targetLocation/>
299               <variable>SETTINGS_FILE</variable>
300             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
301           </managedFiles>
302         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
303         <EnvInjectBuilder>
304           <info>
305             <propertiesContent>SERVER_ID=logs</propertiesContent>
306           </info>
307         </EnvInjectBuilder>
308         <hudson.tasks.Shell>
309           <command>#!/bin/bash
310 # SPDX-License-Identifier: EPL-1.0
311 ##############################################################################
312 # Copyright (c) 2017 The Linux Foundation and others.
313 #
314 # All rights reserved. This program and the accompanying materials
315 # are made available under the terms of the Eclipse Public License v1.0
316 # which accompanies this distribution, and is available at
317 # http://www.eclipse.org/legal/epl-v10.html
318 ##############################################################################
319 echo &quot;---&gt; create-netrc.sh&quot;
320
321 # Ensure we fail the job if any steps fail.
322 set -eu -o pipefail
323
324 NEXUS_URL=&quot;${NEXUS_URL:-$NEXUSPROXY}&quot;
325 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
326     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
327     -v x:username -o &quot;:&quot; -v x:password \
328     &quot;$SETTINGS_FILE&quot;)
329
330 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
331 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
332 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
333
334 echo &quot;machine $machine login $user password $pass&quot; &gt; ~/.netrc
335 </command>
336         </hudson.tasks.Shell>
337         <hudson.tasks.Shell>
338           <command>#!/bin/bash
339 # SPDX-License-Identifier: EPL-1.0
340 ##############################################################################
341 # Copyright (c) 2017 The Linux Foundation and others.
342 #
343 # All rights reserved. This program and the accompanying materials
344 # are made available under the terms of the Eclipse Public License v1.0
345 # which accompanies this distribution, and is available at
346 # http://www.eclipse.org/legal/epl-v10.html
347 ##############################################################################
348 echo &quot;---&gt; lftools-install.sh&quot;
349
350 # By default a released version of lftools should always be used.
351 # The purpose of the 2 variables below is so that lftools devs can test
352 # unreleased versions of lftools. There are 2 methods to install a dev version
353 # of lftools:
354 #
355 #     1) gerrit patch: Used to test a patch that has not yet been merged.
356 #                      To do this set something like this:
357 #                          LFTOOLS_MODE=gerrit
358 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
359 #
360 #     2) git branch: Used to install an lftools version from a specific branch.
361 #                    To use this set the variables as follows:
362 #                          LFTOOLS_MODE=git
363 #                          LFTOOLS_REFSPEC=master
364 #
365 #     3) release : The intended use case and default setting.
366 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
367
368 LFTOOLS_MODE=release  # release | git | gerrit
369 LFTOOLS_REFSPEC=master
370
371 # Ensure we fail the job if any steps fail.
372 # DO NOT set -u as virtualenv's activate script has unbound variables
373 set -e -o pipefail
374
375 virtualenv --quiet &quot;/tmp/v/lftools&quot;
376 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
377 source &quot;/tmp/v/lftools/bin/activate&quot;
378 pip install --quiet --upgrade pip
379
380 case $LFTOOLS_MODE in
381     gerrit)
382         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
383         pushd /tmp/lftools
384         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
385         git checkout FETCH_HEAD
386         pip install --quiet --upgrade -r requirements.txt
387         pip install --quiet --upgrade -e .
388         popd
389         ;;
390
391     git)
392         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
393         ;;
394
395     release)
396         pip install --quiet --upgrade &quot;lftools&lt;1.0.0&quot;
397         ;;
398 esac
399
400 # pipdeptree prints out a lot of information because lftools pulls in many
401 # dependencies. Let's only print it if we want to debug.
402 # echo &quot;----&gt; Pip Dependency Tree&quot;
403 # pip install --quiet --upgrade pipdeptree
404 # pipdeptree
405
406 #!/bin/bash
407 # SPDX-License-Identifier: EPL-1.0
408 ##############################################################################
409 # Copyright (c) 2017 The Linux Foundation and others.
410 #
411 # All rights reserved. This program and the accompanying materials
412 # are made available under the terms of the Eclipse Public License v1.0
413 # which accompanies this distribution, and is available at
414 # http://www.eclipse.org/legal/epl-v10.html
415 ##############################################################################
416 echo &quot;---&gt; logs-deploy.sh&quot;
417
418 # Ensure we fail the job if any steps fail.
419 set -eu -o pipefail
420
421 set -x  # Trace commands for this script to make debugging easier.
422
423 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
424 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
425
426 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
427 then
428     set +x # Disable trace since we no longer need it
429
430     echo &quot;WARNING: Logging server not set&quot;
431 else
432     NEXUS_URL=&quot;${NEXUS_URL:-$NEXUSPROXY}&quot;
433     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
434     BUILD_URL=&quot;${BUILD_URL}&quot;
435
436     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
437     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
438
439     set +x  # Disable trace since we no longer need it.
440
441     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
442 fi
443 </command>
444         </hudson.tasks.Shell>
445         <hudson.tasks.Shell>
446           <command>#!/bin/bash
447 # SPDX-License-Identifier: EPL-1.0
448 ##############################################################################
449 # Copyright (c) 2017 The Linux Foundation and others.
450 #
451 # All rights reserved. This program and the accompanying materials
452 # are made available under the terms of the Eclipse Public License v1.0
453 # which accompanies this distribution, and is available at
454 # http://www.eclipse.org/legal/epl-v10.html
455 ##############################################################################
456
457 # Clear log credential files
458 rm &quot;$SETTINGS_FILE&quot;
459 rm ~/.netrc
460 </command>
461         </hudson.tasks.Shell>
462         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
463           <regexp>^Build logs: .*</regexp>
464         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
465       </buildSteps>
466       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
467       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
468       <markBuildUnstable>false</markBuildUnstable>
469     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
470     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
471       <patterns>
472         <hudson.plugins.ws__cleanup.Pattern>
473           <pattern>**/*.jenkins-trigger</pattern>
474           <type>EXCLUDE</type>
475         </hudson.plugins.ws__cleanup.Pattern>
476       </patterns>
477       <deleteDirs>false</deleteDirs>
478       <cleanupMatrixParent>false</cleanupMatrixParent>
479       <externalDelete/>
480       <cleanWhenSuccess>true</cleanWhenSuccess>
481       <cleanWhenUnstable>true</cleanWhenUnstable>
482       <cleanWhenFailure>true</cleanWhenFailure>
483       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
484       <cleanWhenAborted>true</cleanWhenAborted>
485       <notFailBuild>true</notFailBuild>
486     </hudson.plugins.ws__cleanup.WsCleanup>
487   </publishers>
488   <buildWrappers>
489     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
490     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
491       <timeoutMinutes>10</timeoutMinutes>
492       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
493       <failBuild>true</failBuild>
494       <writingDescription>false</writingDescription>
495       <timeoutPercentage>0</timeoutPercentage>
496       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
497       <timeoutType>absolute</timeoutType>
498     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
499     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
500     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
501       <user>test-credential</user>
502     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
503     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
504   </buildWrappers>
505 </project>