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