Add a check for missing vars/*.json
[releng/global-jjb.git] / .jjb-test / expected-xml / gerrit-ciman-packer-merge-ubuntu1604-java-builder
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>false</concurrentBuild>
9   <assignedNode>build-vm</assignedNode>
10   <canRoam>false</canRoam>
11   <properties>
12     <jenkins.model.BuildDiscarderProperty>
13       <strategy class="hudson.tasks.LogRotator">
14         <daysToKeep>7</daysToKeep>
15         <numToKeep>-1</numToKeep>
16         <artifactDaysToKeep>-1</artifactDaysToKeep>
17         <artifactNumToKeep>0</artifactNumToKeep>
18       </strategy>
19     </jenkins.model.BuildDiscarderProperty>
20     <hudson.model.ParametersDefinitionProperty>
21       <parameterDefinitions>
22         <hudson.model.StringParameterDefinition>
23           <name>PROJECT</name>
24           <description>Parameter to identify a Gerrit project. This is typically the
25 project repo path as exists in Gerrit.
26 For example: ofextensions/circuitsw
27 </description>
28           <defaultValue>releng/ciman</defaultValue>
29         </hudson.model.StringParameterDefinition>
30         <hudson.model.StringParameterDefinition>
31           <name>STREAM</name>
32           <description>Stream is often set to the same name as 'branch' but can
33 sometimes be used as a name representing a project's release code
34 name.
35 </description>
36           <defaultValue>master</defaultValue>
37         </hudson.model.StringParameterDefinition>
38         <hudson.model.StringParameterDefinition>
39           <name>GERRIT_PROJECT</name>
40           <description>Parameter to identify Gerrit project. This is typically the
41 project repo path as exists in Gerrit.
42 For example: ofextensions/circuitsw
43
44 Note that Gerrit will override this parameter automatically if a
45 job is triggered by Gerrit.
46 </description>
47           <defaultValue>releng/ciman</defaultValue>
48         </hudson.model.StringParameterDefinition>
49         <hudson.model.StringParameterDefinition>
50           <name>GERRIT_BRANCH</name>
51           <description>Parameter to identify a Gerrit branch.
52
53 Note that Gerrit will override this parameter automatically if a
54 job is triggered by Gerrit.
55 </description>
56           <defaultValue>master</defaultValue>
57         </hudson.model.StringParameterDefinition>
58         <hudson.model.StringParameterDefinition>
59           <name>GERRIT_REFSPEC</name>
60           <description>Parameter to identify a refspec when pulling from Gerrit.
61
62 Note that Gerrit will override this parameter automatically if a
63 job is triggered by Gerrit.
64 </description>
65           <defaultValue>refs/heads/master</defaultValue>
66         </hudson.model.StringParameterDefinition>
67         <hudson.model.StringParameterDefinition>
68           <name>LFTOOLS_VERSION</name>
69           <description>Version of lftools to install. Can be a specific version like
70 '0.6.0' or a PEP-440 definition.
71 https://www.python.org/dev/peps/pep-0440/
72 For example '&lt;1.0.0' or '&gt;=1.0.0,&lt;2.0.0'.
73 </description>
74           <defaultValue>&lt;1.0.0</defaultValue>
75         </hudson.model.StringParameterDefinition>
76         <hudson.model.StringParameterDefinition>
77           <name>PACKER_VERSION</name>
78           <description>Packer version to download and install.</description>
79           <defaultValue>1.1.3</defaultValue>
80         </hudson.model.StringParameterDefinition>
81       </parameterDefinitions>
82     </hudson.model.ParametersDefinitionProperty>
83   </properties>
84   <scm class="hudson.plugins.git.GitSCM">
85     <configVersion>2</configVersion>
86     <userRemoteConfigs>
87       <hudson.plugins.git.UserRemoteConfig>
88         <name>origin</name>
89         <refspec>$GERRIT_REFSPEC</refspec>
90         <url>$GIT_URL/$GERRIT_PROJECT</url>
91         <credentialsId>test-credential</credentialsId>
92       </hudson.plugins.git.UserRemoteConfig>
93     </userRemoteConfigs>
94     <branches>
95       <hudson.plugins.git.BranchSpec>
96         <name>refs/heads/$GERRIT_BRANCH</name>
97       </hudson.plugins.git.BranchSpec>
98     </branches>
99     <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
100     <remotePoll>false</remotePoll>
101     <gitTool>Default</gitTool>
102     <submoduleCfg class="list"/>
103     <reference/>
104     <gitConfigName/>
105     <gitConfigEmail/>
106     <extensions>
107       <hudson.plugins.git.extensions.impl.BuildChooserSetting>
108         <buildChooser class="com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser"/>
109       </hudson.plugins.git.extensions.impl.BuildChooserSetting>
110       <hudson.plugins.git.extensions.impl.SubmoduleOption>
111         <disableSubmodules>false</disableSubmodules>
112         <recursiveSubmodules>true</recursiveSubmodules>
113         <trackingSubmodules>false</trackingSubmodules>
114         <parentCredentials>false</parentCredentials>
115         <reference/>
116         <timeout>10</timeout>
117       </hudson.plugins.git.extensions.impl.SubmoduleOption>
118       <hudson.plugins.git.extensions.impl.WipeWorkspace/>
119     </extensions>
120   </scm>
121   <triggers class="vector">
122     <hudson.triggers.TimerTrigger>
123       <spec>00 10 1 * *</spec>
124     </hudson.triggers.TimerTrigger>
125     <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
126       <spec/>
127       <gerritProjects>
128         <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
129           <compareType>ANT</compareType>
130           <pattern>releng/ciman</pattern>
131           <branches>
132             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
133               <compareType>ANT</compareType>
134               <pattern>**/master</pattern>
135             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
136           </branches>
137           <filePaths>
138             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
139               <compareType>ANT</compareType>
140               <pattern>packer/vars/ubuntu1604.json</pattern>
141             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
142             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
143               <compareType>ANT</compareType>
144               <pattern>packer/templates/java-builder.json</pattern>
145             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
146             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
147               <compareType>ANT</compareType>
148               <pattern>packer/provision/*.sh</pattern>
149             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
150             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
151               <compareType>ANT</compareType>
152               <pattern>packer/provision/java-builder.yaml</pattern>
153             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
154             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
155               <compareType>ANT</compareType>
156               <pattern>packer/provision/lib/**</pattern>
157             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
158           </filePaths>
159           <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
160         </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
161       </gerritProjects>
162       <skipVote>
163         <onSuccessful>false</onSuccessful>
164         <onFailed>false</onFailed>
165         <onUnstable>false</onUnstable>
166         <onNotBuilt>false</onNotBuilt>
167       </skipVote>
168       <silentMode>false</silentMode>
169       <silentStartMode>false</silentStartMode>
170       <escapeQuotes>true</escapeQuotes>
171       <noNameAndEmailParameters>false</noNameAndEmailParameters>
172       <readableMessage>false</readableMessage>
173       <dependencyJobsNames/>
174       <notificationLevel/>
175       <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
176       <triggerConfigURL/>
177       <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
178       <triggerOnEvents>
179         <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginChangeMergedEvent/>
180         <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
181           <commentAddedCommentContains>remerge$</commentAddedCommentContains>
182         </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
183       </triggerOnEvents>
184       <buildStartMessage/>
185       <buildFailureMessage/>
186       <buildSuccessfulMessage/>
187       <buildUnstableMessage/>
188       <buildNotBuiltMessage/>
189       <buildUnsuccessfulFilepath/>
190       <customUrl/>
191       <serverName>test-server</serverName>
192     </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
193   </triggers>
194   <builders>
195     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
196       <managedFiles>
197         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
198           <fileId>ci-packer-cloud-env</fileId>
199           <targetLocation/>
200           <variable>CLOUDENV</variable>
201         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
202       </managedFiles>
203     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
204     <EnvInjectBuilder>
205       <info>
206         <propertiesContent>PACKER_VERSION=1.1.3
207 </propertiesContent>
208       </info>
209     </EnvInjectBuilder>
210     <hudson.tasks.Shell>
211       <command>#!/bin/bash
212 # SPDX-License-Identifier: EPL-1.0
213 ##############################################################################
214 # Copyright (c) 2017 The Linux Foundation and others.
215 #
216 # All rights reserved. This program and the accompanying materials
217 # are made available under the terms of the Eclipse Public License v1.0
218 # which accompanies this distribution, and is available at
219 # http://www.eclipse.org/legal/epl-v10.html
220 ##############################################################################
221 echo &quot;---&gt; packer-install.sh&quot;
222 # The script checks for the packer binaries and installs the binary
223 # if its not available
224
225 # $PACKER_VERSION        : Define a packer version passed as job paramter
226
227 PACKER_VERSION=&quot;${PACKER_VERSION:-1.1.3}&quot;
228
229 # Ensure we fail the job if any steps fail.
230 set -eu -o pipefail
231
232 if hash packer.io 2&gt;/dev/null; then
233     echo &quot;packer.io command is available.&quot;
234 else
235     echo &quot;packer.io command not is available. Installing packer ...&quot;
236     # Installs Hashicorp's Packer binary, required for verify &amp; merge packer jobs
237     pushd &quot;${WORKSPACE}&quot;
238     wget -nv &quot;https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip&quot;
239     mkdir -p &quot;${WORKSPACE}/bin&quot;
240     unzip &quot;packer_${PACKER_VERSION}_linux_amd64.zip&quot; -d &quot;${WORKSPACE}/bin/&quot;
241     # rename packer to avoid conflict with binary in cracklib
242     mv &quot;${WORKSPACE}/bin/packer&quot; &quot;${WORKSPACE}/bin/packer.io&quot;
243     popd
244 fi
245
246 #!/bin/bash
247 # SPDX-License-Identifier: EPL-1.0
248 ##############################################################################
249 # Copyright (c) 2017 The Linux Foundation and others.
250 #
251 # All rights reserved. This program and the accompanying materials
252 # are made available under the terms of the Eclipse Public License v1.0
253 # which accompanies this distribution, and is available at
254 # http://www.eclipse.org/legal/epl-v10.html
255 ##############################################################################
256 echo &quot;---&gt; packer-validate.sh&quot;
257 # The script validates an packers files.
258
259 # $CLOUDENV            :  Provides the cloud credential file.
260
261 # Ensure we fail the job if any steps fail.
262 set -eu -o pipefail
263
264 PACKER_LOGS_DIR=&quot;$WORKSPACE/archives/packer&quot;
265 mkdir -p &quot;$PACKER_LOGS_DIR&quot;
266 export PATH=&quot;${WORKSPACE}/bin:$PATH&quot;
267
268 cd packer
269 varfiles=(vars/*.json common-packer/vars/*.json)
270 templates=(templates/*.json)
271
272 for varfile in &quot;${varfiles[@]}&quot;; do
273     # cloud-env.json is a file containing credentials which is pulled in via
274     # CLOUDENV variable so skip it here. Also handle the case where a project
275     # has not vars/*.json file.
276     if [[ &quot;$varfile&quot; == *&quot;cloud-env.json&quot;* ]] || [[ &quot;$varfile&quot; == 'vars/*.json' ]]; then
277         continue
278     fi
279
280     echo &quot;-----&gt; Testing varfile: $varfile&quot;
281     for template in &quot;${templates[@]}&quot;; do
282         export PACKER_LOG=&quot;yes&quot;
283         export PACKER_LOG_PATH=&quot;$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log&quot;
284         if output=$(packer.io validate -var-file=&quot;$CLOUDENV&quot; -var-file=&quot;$varfile&quot; &quot;$template&quot;); then
285             echo &quot;$template: $output&quot;
286         else
287             echo &quot;$template: $output&quot;
288             exit 1
289         fi
290     done
291 done
292 </command>
293     </hudson.tasks.Shell>
294     <hudson.tasks.Shell>
295       <command>#!/bin/bash
296 # SPDX-License-Identifier: EPL-1.0
297 ##############################################################################
298 # Copyright (c) 2017 The Linux Foundation and others.
299 #
300 # All rights reserved. This program and the accompanying materials
301 # are made available under the terms of the Eclipse Public License v1.0
302 # which accompanies this distribution, and is available at
303 # http://www.eclipse.org/legal/epl-v10.html
304 ##############################################################################
305 echo &quot;---&gt; packer-clear-credentials.sh&quot;
306
307 set +e  # DO NOT cause build failure if any of the rm calls fail.
308 rm &quot;$CLOUDENV&quot;
309 exit 0
310 </command>
311     </hudson.tasks.Shell>
312     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
313       <managedFiles>
314         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
315           <fileId>ci-packer-cloud-env</fileId>
316           <targetLocation/>
317           <variable>CLOUDENV</variable>
318         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
319       </managedFiles>
320     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
321     <EnvInjectBuilder>
322       <info>
323         <propertiesContent>PACKER_PLATFORM=ubuntu1604
324 PACKER_TEMPLATE=java-builder
325 PACKER_VERSION=1.1.3
326 </propertiesContent>
327       </info>
328     </EnvInjectBuilder>
329     <hudson.tasks.Shell>
330       <command>#!/bin/bash
331 # SPDX-License-Identifier: EPL-1.0
332 ##############################################################################
333 # Copyright (c) 2017 The Linux Foundation and others.
334 #
335 # All rights reserved. This program and the accompanying materials
336 # are made available under the terms of the Eclipse Public License v1.0
337 # which accompanies this distribution, and is available at
338 # http://www.eclipse.org/legal/epl-v10.html
339 ##############################################################################
340 echo &quot;---&gt; packer-install.sh&quot;
341 # The script checks for the packer binaries and installs the binary
342 # if its not available
343
344 # $PACKER_VERSION        : Define a packer version passed as job paramter
345
346 PACKER_VERSION=&quot;${PACKER_VERSION:-1.1.3}&quot;
347
348 # Ensure we fail the job if any steps fail.
349 set -eu -o pipefail
350
351 if hash packer.io 2&gt;/dev/null; then
352     echo &quot;packer.io command is available.&quot;
353 else
354     echo &quot;packer.io command not is available. Installing packer ...&quot;
355     # Installs Hashicorp's Packer binary, required for verify &amp; merge packer jobs
356     pushd &quot;${WORKSPACE}&quot;
357     wget -nv &quot;https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip&quot;
358     mkdir -p &quot;${WORKSPACE}/bin&quot;
359     unzip &quot;packer_${PACKER_VERSION}_linux_amd64.zip&quot; -d &quot;${WORKSPACE}/bin/&quot;
360     # rename packer to avoid conflict with binary in cracklib
361     mv &quot;${WORKSPACE}/bin/packer&quot; &quot;${WORKSPACE}/bin/packer.io&quot;
362     popd
363 fi
364
365 #!/bin/bash
366 # SPDX-License-Identifier: EPL-1.0
367 ##############################################################################
368 # Copyright (c) 2017 The Linux Foundation and others.
369 #
370 # All rights reserved. This program and the accompanying materials
371 # are made available under the terms of the Eclipse Public License v1.0
372 # which accompanies this distribution, and is available at
373 # http://www.eclipse.org/legal/epl-v10.html
374 ##############################################################################
375 echo &quot;---&gt; packer-build.sh&quot;
376 # The script builds an image using packer
377 # $CLOUDENV            :  Provides the cloud credential file.
378 # $PACKER_PLATFORM     :  Provides the packer platform.
379 # $PACKER_TEMPLATE     :  Provides the packer temnplate.
380
381 # Ensure we fail the job if any steps fail.
382 set -eu -o pipefail
383
384 PACKER_LOGS_DIR=&quot;$WORKSPACE/archives/packer&quot;
385 PACKER_BUILD_LOG=&quot;$PACKER_LOGS_DIR/packer-build.log&quot;
386 mkdir -p &quot;$PACKER_LOGS_DIR&quot;
387 export PATH=&quot;${WORKSPACE}/bin:$PATH&quot;
388
389 # Prioritize the project's own version of vars if available
390 platform_file=&quot;vars/$PACKER_PLATFORM.json&quot;
391 if [ -f &quot;$PACKER_PLATFORM&quot; ]; then
392     platform_file=&quot;vars/$PACKER_PLATFORM.json&quot;
393 fi
394
395 cd packer
396 export PACKER_LOG=&quot;yes&quot;
397 export PACKER_LOG_PATH=&quot;$PACKER_BUILD_LOG&quot;
398 packer.io build -color=false \
399     -var-file=&quot;$CLOUDENV&quot; \
400     -var-file=&quot;$platform_file&quot; \
401     &quot;templates/$PACKER_TEMPLATE.json&quot;
402
403 # Retrive the list of cloud providers
404 mapfile -t clouds &lt; &lt;(jq -r '.builders[].name' &quot;templates/$PACKER_TEMPLATE.json&quot;)
405
406 # Split public/private clouds logs
407 for cloud in &quot;${clouds[@]}&quot;; do
408     grep -e &quot;$cloud&quot; &quot;$PACKER_BUILD_LOG&quot; &gt; &quot;$PACKER_LOGS_DIR/packer-build_$cloud.log&quot; 2&gt;&amp;1
409 done
410 </command>
411     </hudson.tasks.Shell>
412     <hudson.tasks.Shell>
413       <command>#!/bin/bash
414 # SPDX-License-Identifier: EPL-1.0
415 ##############################################################################
416 # Copyright (c) 2017 The Linux Foundation and others.
417 #
418 # All rights reserved. This program and the accompanying materials
419 # are made available under the terms of the Eclipse Public License v1.0
420 # which accompanies this distribution, and is available at
421 # http://www.eclipse.org/legal/epl-v10.html
422 ##############################################################################
423 echo &quot;---&gt; packer-clear-credentials.sh&quot;
424
425 set +e  # DO NOT cause build failure if any of the rm calls fail.
426 rm &quot;$CLOUDENV&quot;
427 exit 0
428 </command>
429     </hudson.tasks.Shell>
430   </builders>
431   <publishers>
432     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
433       <buildSteps>
434         <hudson.tasks.Shell>
435           <command>#!/bin/bash
436 # SPDX-License-Identifier: EPL-1.0
437 ##############################################################################
438 # Copyright (c) 2017 The Linux Foundation and others.
439 #
440 # All rights reserved. This program and the accompanying materials
441 # are made available under the terms of the Eclipse Public License v1.0
442 # which accompanies this distribution, and is available at
443 # http://www.eclipse.org/legal/epl-v10.html
444 ##############################################################################
445 echo &quot;---&gt; sysstat.sh&quot;
446 set +e  # DON'T fail build if script fails.
447
448 OS=$(facter operatingsystem)
449 case &quot;$OS&quot; in
450     Ubuntu)
451         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
452
453         # Dont run the script when systat is not enabled by default
454         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
455             exit 0
456         fi
457     ;;
458     CentOS|RedHat)
459         SYSSTAT_PATH=&quot;/var/log/sa&quot;
460     ;;
461     *)
462         # nothing to do
463         exit 0
464     ;;
465 esac
466
467 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
468 mkdir -p &quot;$SAR_DIR&quot;
469 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
470 # convert sar data to ascii format
471 while IFS=&quot;&quot; read -r sarfilenum
472 do
473     [ -f &quot;$sarfilenum&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$sarfilenum&quot; &gt; &quot;$SAR_DIR/sar${sarfilenum//[!0-9]/}&quot;
474 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
475
476 # DON'T fail build if script fails.
477 exit 0
478 </command>
479         </hudson.tasks.Shell>
480         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
481           <managedFiles>
482             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
483               <fileId>jenkins-log-archives-settings</fileId>
484               <targetLocation/>
485               <variable>SETTINGS_FILE</variable>
486             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
487           </managedFiles>
488         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
489         <EnvInjectBuilder>
490           <info>
491             <propertiesContent>SERVER_ID=logs</propertiesContent>
492           </info>
493         </EnvInjectBuilder>
494         <hudson.tasks.Shell>
495           <command>#!/bin/bash
496 # SPDX-License-Identifier: EPL-1.0
497 ##############################################################################
498 # Copyright (c) 2017 The Linux Foundation and others.
499 #
500 # All rights reserved. This program and the accompanying materials
501 # are made available under the terms of the Eclipse Public License v1.0
502 # which accompanies this distribution, and is available at
503 # http://www.eclipse.org/legal/epl-v10.html
504 ##############################################################################
505 echo &quot;---&gt; create-netrc.sh&quot;
506
507 # Ensure we fail the job if any steps fail.
508 set -eu -o pipefail
509
510 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
511 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
512     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
513     -v x:username -o &quot;:&quot; -v x:password \
514     &quot;$SETTINGS_FILE&quot;)
515
516 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
517 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
518 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
519
520 echo &quot;machine ${machine%:*} login $user password $pass&quot; &gt; ~/.netrc
521 </command>
522         </hudson.tasks.Shell>
523         <hudson.tasks.Shell>
524           <command>#!/bin/bash
525 # SPDX-License-Identifier: EPL-1.0
526 ##############################################################################
527 # Copyright (c) 2017 The Linux Foundation and others.
528 #
529 # All rights reserved. This program and the accompanying materials
530 # are made available under the terms of the Eclipse Public License v1.0
531 # which accompanies this distribution, and is available at
532 # http://www.eclipse.org/legal/epl-v10.html
533 ##############################################################################
534 echo &quot;---&gt; lftools-install.sh&quot;
535
536 # Script to install lftools via a version passed in via lf-infra-parameters
537 #
538 # Required parameters:
539 #
540 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
541 #                      set to a strict version number like '1.2.3' or using
542 #                      PEP-440 definitions.
543 #
544 #                      Examples:
545 #                          &lt;1.0.0
546 #                          &gt;=1.0.0,&lt;2.0.0
547 #
548 # By default a released version of lftools should always be used.
549 # The purpose of the 2 variables below is so that lftools devs can test
550 # unreleased versions of lftools. There are 2 methods to install a dev version
551 # of lftools:
552 #
553 #     1) gerrit patch: Used to test a patch that has not yet been merged.
554 #                      To do this set something like this:
555 #                          LFTOOLS_MODE=gerrit
556 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
557 #
558 #     2) git branch: Used to install an lftools version from a specific branch.
559 #                    To use this set the variables as follows:
560 #                          LFTOOLS_MODE=git
561 #                          LFTOOLS_REFSPEC=master
562 #
563 #     3) release : The intended use case and default setting.
564 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
565
566 LFTOOLS_MODE=release  # release | git | gerrit
567 LFTOOLS_REFSPEC=master
568
569 # Ensure we fail the job if any steps fail.
570 # DO NOT set -u as virtualenv's activate script has unbound variables
571 set -e -o pipefail
572
573 virtualenv --quiet &quot;/tmp/v/lftools&quot;
574 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
575 source &quot;/tmp/v/lftools/bin/activate&quot;
576 pip install --quiet --upgrade pip
577
578 case $LFTOOLS_MODE in
579     gerrit)
580         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
581         pushd /tmp/lftools
582         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
583         git checkout FETCH_HEAD
584         pip install --quiet --upgrade -r requirements.txt
585         pip install --quiet --upgrade -e .
586         popd
587         ;;
588
589     git)
590         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
591         ;;
592
593     release)
594         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
595             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
596         fi
597
598         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
599         ;;
600 esac
601
602 lftools --version
603
604 # pipdeptree prints out a lot of information because lftools pulls in many
605 # dependencies. Let's only print it if we want to debug.
606 # echo &quot;----&gt; Pip Dependency Tree&quot;
607 # pip install --quiet --upgrade pipdeptree
608 # pipdeptree
609
610 #!/bin/bash
611 # SPDX-License-Identifier: EPL-1.0
612 ##############################################################################
613 # Copyright (c) 2017 The Linux Foundation and others.
614 #
615 # All rights reserved. This program and the accompanying materials
616 # are made available under the terms of the Eclipse Public License v1.0
617 # which accompanies this distribution, and is available at
618 # http://www.eclipse.org/legal/epl-v10.html
619 ##############################################################################
620 echo &quot;---&gt; logs-deploy.sh&quot;
621
622 # Ensure we fail the job if any steps fail.
623 set -eu -o pipefail
624
625 set -x  # Trace commands for this script to make debugging easier.
626
627 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
628 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
629
630 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
631 then
632     set +x # Disable trace since we no longer need it
633
634     echo &quot;WARNING: Logging server not set&quot;
635 else
636     NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
637     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
638     BUILD_URL=&quot;${BUILD_URL}&quot;
639
640     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
641     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
642
643     set +x  # Disable trace since we no longer need it.
644
645     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
646 fi
647 </command>
648         </hudson.tasks.Shell>
649         <hudson.tasks.Shell>
650           <command>#!/bin/bash
651 # SPDX-License-Identifier: EPL-1.0
652 ##############################################################################
653 # Copyright (c) 2017 The Linux Foundation and others.
654 #
655 # All rights reserved. This program and the accompanying materials
656 # are made available under the terms of the Eclipse Public License v1.0
657 # which accompanies this distribution, and is available at
658 # http://www.eclipse.org/legal/epl-v10.html
659 ##############################################################################
660
661 # Clear log credential files
662 rm &quot;$SETTINGS_FILE&quot;
663 rm ~/.netrc
664 </command>
665         </hudson.tasks.Shell>
666         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
667           <regexp>^Build logs: .*</regexp>
668         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
669       </buildSteps>
670       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
671       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
672       <markBuildUnstable>false</markBuildUnstable>
673     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
674     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
675       <patterns>
676         <hudson.plugins.ws__cleanup.Pattern>
677           <pattern>**/*.jenkins-trigger</pattern>
678           <type>EXCLUDE</type>
679         </hudson.plugins.ws__cleanup.Pattern>
680       </patterns>
681       <deleteDirs>false</deleteDirs>
682       <cleanupMatrixParent>false</cleanupMatrixParent>
683       <externalDelete/>
684       <cleanWhenSuccess>true</cleanWhenSuccess>
685       <cleanWhenUnstable>true</cleanWhenUnstable>
686       <cleanWhenFailure>true</cleanWhenFailure>
687       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
688       <cleanWhenAborted>true</cleanWhenAborted>
689       <notFailBuild>true</notFailBuild>
690     </hudson.plugins.ws__cleanup.WsCleanup>
691   </publishers>
692   <buildWrappers>
693     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
694     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
695       <timeoutMinutes>45</timeoutMinutes>
696       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
697       <failBuild>true</failBuild>
698       <writingDescription>false</writingDescription>
699       <timeoutPercentage>0</timeoutPercentage>
700       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
701       <timeoutType>absolute</timeoutType>
702     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
703     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
704     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
705       <user>test-credential</user>
706     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
707     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
708     <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
709       <managedFiles>
710         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
711           <fileId>npmrc</fileId>
712           <targetLocation>$HOME/.npmrc</targetLocation>
713           <variable/>
714         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
715       </managedFiles>
716     </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
717   </buildWrappers>
718 </project>