Merge "Let NEXUSPROXY override NEXUS_URL if both are set"
[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.1</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.1
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.0.2}&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=(../packer/vars/*.json)
272 templates=(../packer/templates/*.json)
273
274 for varfile in &quot;${varfiles[@]}&quot;; do
275     for template in &quot;${templates[@]}&quot;; do
276         export PACKER_LOG=&quot;yes&quot; &amp;&amp; \
277         export PACKER_LOG_PATH=&quot;$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log&quot; &amp;&amp; \
278                     packer.io validate -var-file=&quot;$CLOUDENV&quot; \
279                     -var-file=&quot;$varfile&quot; &quot;$template&quot;
280         if [ $? -ne 0 ]; then
281             break
282         fi
283     done
284 done
285 </command>
286     </hudson.tasks.Shell>
287     <hudson.tasks.Shell>
288       <command>#!/bin/bash
289 # SPDX-License-Identifier: EPL-1.0
290 ##############################################################################
291 # Copyright (c) 2017 The Linux Foundation and others.
292 #
293 # All rights reserved. This program and the accompanying materials
294 # are made available under the terms of the Eclipse Public License v1.0
295 # which accompanies this distribution, and is available at
296 # http://www.eclipse.org/legal/epl-v10.html
297 ##############################################################################
298 echo &quot;---&gt; packer-clear-credentials.sh&quot;
299
300 set +e  # DO NOT cause build failure if any of the rm calls fail.
301 rm &quot;$CLOUDENV&quot;
302 exit 0
303 </command>
304     </hudson.tasks.Shell>
305     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
306       <managedFiles>
307         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
308           <fileId>ci-packer-cloud-env</fileId>
309           <targetLocation/>
310           <variable>CLOUDENV</variable>
311         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
312       </managedFiles>
313     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
314     <EnvInjectBuilder>
315       <info>
316         <propertiesContent>PACKER_PLATFORM=centos
317 PACKER_TEMPLATE=java-builder
318 PACKER_VERSION=1.1.1
319 </propertiesContent>
320       </info>
321     </EnvInjectBuilder>
322     <hudson.tasks.Shell>
323       <command>#!/bin/bash
324 # SPDX-License-Identifier: EPL-1.0
325 ##############################################################################
326 # Copyright (c) 2017 The Linux Foundation and others.
327 #
328 # All rights reserved. This program and the accompanying materials
329 # are made available under the terms of the Eclipse Public License v1.0
330 # which accompanies this distribution, and is available at
331 # http://www.eclipse.org/legal/epl-v10.html
332 ##############################################################################
333 echo &quot;---&gt; packer-install.sh&quot;
334 # The script checks for the packer binaries and installs the binary
335 # if its not available
336
337 # $PACKER_VERSION        : Define a packer version passed as job paramter
338
339 PACKER_VERSION=&quot;${PACKER_VERSION:-1.0.2}&quot;
340
341 # Ensure we fail the job if any steps fail.
342 set -eu -o pipefail
343
344 if hash packer.io 2&gt;/dev/null; then
345     echo &quot;packer.io command is available.&quot;
346 else
347     echo &quot;packer.io command not is available. Installing packer ...&quot;
348     # Installs Hashicorp's Packer binary, required for verify &amp; merge packer jobs
349     pushd packer
350     wget -nv &quot;https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip&quot;
351     mkdir -p &quot;${WORKSPACE}/bin&quot;
352     unzip &quot;packer_${PACKER_VERSION}_linux_amd64.zip&quot; -d ${WORKSPACE}/bin/
353     # rename packer to avoid conflict with binary in cracklib
354     mv ${WORKSPACE}/bin/packer &quot;${WORKSPACE}/bin/packer.io&quot;
355     popd
356 fi
357
358 #!/bin/bash
359 # SPDX-License-Identifier: EPL-1.0
360 ##############################################################################
361 # Copyright (c) 2017 The Linux Foundation and others.
362 #
363 # All rights reserved. This program and the accompanying materials
364 # are made available under the terms of the Eclipse Public License v1.0
365 # which accompanies this distribution, and is available at
366 # http://www.eclipse.org/legal/epl-v10.html
367 ##############################################################################
368 echo &quot;---&gt; packer-build.sh&quot;
369 # The script builds an image using packer
370 # $CLOUDENV            :  Provides the cloud credential file.
371 # $PACKER_PLATFORM     :  Provides the packer platform.
372 # $PACKER_TEMPLATE     :  Provides the packer temnplate.
373
374 # Ensure we fail the job if any steps fail.
375 set -eu -o pipefail
376
377 PACKER_LOGS_DIR=&quot;$WORKSPACE/archives/packer&quot;
378 PACKER_BUILD_LOG=&quot;$PACKER_LOGS_DIR/packer-build.log&quot;
379 mkdir -p &quot;$PACKER_LOGS_DIR&quot;
380 export PATH=&quot;${WORKSPACE}/bin:$PATH&quot;
381
382 cd packer
383 export PACKER_LOG=&quot;yes&quot; &amp;&amp; \
384 export PACKER_LOG_PATH=&quot;$PACKER_BUILD_LOG&quot; &amp;&amp; \
385                  packer.io build -color=false \
386                         -var-file=&quot;$CLOUDENV&quot; \
387                         -var-file=&quot;../packer/vars/$PACKER_PLATFORM.json&quot; \
388                         &quot;../packer/templates/$PACKER_TEMPLATE.json&quot;
389
390 # Retrive the list of cloud providers
391 clouds=($(jq -r '.builders[].name' &quot;../packer/templates/$PACKER_TEMPLATE.json&quot;))
392
393 # Split public/private clouds logs
394 for cloud in &quot;${clouds[@]}&quot;; do
395     grep -e &quot;$cloud&quot; &quot;$PACKER_BUILD_LOG&quot; &gt; &quot;$PACKER_LOGS_DIR/packer-build_$cloud.log&quot; 2&gt;&amp;1
396 done
397 </command>
398     </hudson.tasks.Shell>
399     <hudson.tasks.Shell>
400       <command>#!/bin/bash
401 # SPDX-License-Identifier: EPL-1.0
402 ##############################################################################
403 # Copyright (c) 2017 The Linux Foundation and others.
404 #
405 # All rights reserved. This program and the accompanying materials
406 # are made available under the terms of the Eclipse Public License v1.0
407 # which accompanies this distribution, and is available at
408 # http://www.eclipse.org/legal/epl-v10.html
409 ##############################################################################
410 echo &quot;---&gt; packer-clear-credentials.sh&quot;
411
412 set +e  # DO NOT cause build failure if any of the rm calls fail.
413 rm &quot;$CLOUDENV&quot;
414 exit 0
415 </command>
416     </hudson.tasks.Shell>
417   </builders>
418   <publishers>
419     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
420       <buildSteps>
421         <hudson.tasks.Shell>
422           <command>#!/bin/bash
423 # SPDX-License-Identifier: EPL-1.0
424 ##############################################################################
425 # Copyright (c) 2017 The Linux Foundation and others.
426 #
427 # All rights reserved. This program and the accompanying materials
428 # are made available under the terms of the Eclipse Public License v1.0
429 # which accompanies this distribution, and is available at
430 # http://www.eclipse.org/legal/epl-v10.html
431 ##############################################################################
432 echo &quot;---&gt; sysstat.sh&quot;
433 set +e  # DON'T fail build if script fails.
434
435 OS=$(facter operatingsystem)
436 case &quot;$OS&quot; in
437     Ubuntu)
438         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
439
440         # Dont run the script when systat is not enabled by default
441         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
442             exit 0
443         fi
444     ;;
445     CentOS|RedHat)
446         SYSSTAT_PATH=&quot;/var/log/sa&quot;
447     ;;
448     *)
449         # nothing to do
450         exit 0
451     ;;
452 esac
453
454 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
455 mkdir -p &quot;$SAR_DIR&quot;
456 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
457 # convert sar data to ascii format
458 while IFS=&quot;&quot; read -r s
459 do
460     [ -f &quot;$s&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$s&quot; &gt; &quot;$SAR_DIR/sar${s//[!0-9]/}&quot;
461 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
462
463 # DON'T fail build if script fails.
464 exit 0
465 </command>
466         </hudson.tasks.Shell>
467         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
468           <managedFiles>
469             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
470               <fileId>jenkins-log-archives-settings</fileId>
471               <targetLocation/>
472               <variable>SETTINGS_FILE</variable>
473             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
474           </managedFiles>
475         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
476         <EnvInjectBuilder>
477           <info>
478             <propertiesContent>SERVER_ID=logs</propertiesContent>
479           </info>
480         </EnvInjectBuilder>
481         <hudson.tasks.Shell>
482           <command>#!/bin/bash
483 # SPDX-License-Identifier: EPL-1.0
484 ##############################################################################
485 # Copyright (c) 2017 The Linux Foundation and others.
486 #
487 # All rights reserved. This program and the accompanying materials
488 # are made available under the terms of the Eclipse Public License v1.0
489 # which accompanies this distribution, and is available at
490 # http://www.eclipse.org/legal/epl-v10.html
491 ##############################################################################
492 echo &quot;---&gt; create-netrc.sh&quot;
493
494 # Ensure we fail the job if any steps fail.
495 set -eu -o pipefail
496
497 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
498 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
499     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
500     -v x:username -o &quot;:&quot; -v x:password \
501     &quot;$SETTINGS_FILE&quot;)
502
503 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
504 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
505 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
506
507 echo &quot;machine $machine login $user password $pass&quot; &gt; ~/.netrc
508 </command>
509         </hudson.tasks.Shell>
510         <hudson.tasks.Shell>
511           <command>#!/bin/bash
512 # SPDX-License-Identifier: EPL-1.0
513 ##############################################################################
514 # Copyright (c) 2017 The Linux Foundation and others.
515 #
516 # All rights reserved. This program and the accompanying materials
517 # are made available under the terms of the Eclipse Public License v1.0
518 # which accompanies this distribution, and is available at
519 # http://www.eclipse.org/legal/epl-v10.html
520 ##############################################################################
521 echo &quot;---&gt; lftools-install.sh&quot;
522
523 # Script to install lftools via a version passed in via lf-infra-parameters
524 #
525 # Required parameters:
526 #
527 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
528 #                      set to a strict version number like '1.2.3' or using
529 #                      PEP-440 definitions.
530 #
531 #                      Examples:
532 #                          &lt;1.0.0
533 #                          &gt;=1.0.0,&lt;2.0.0
534 #
535 # By default a released version of lftools should always be used.
536 # The purpose of the 2 variables below is so that lftools devs can test
537 # unreleased versions of lftools. There are 2 methods to install a dev version
538 # of lftools:
539 #
540 #     1) gerrit patch: Used to test a patch that has not yet been merged.
541 #                      To do this set something like this:
542 #                          LFTOOLS_MODE=gerrit
543 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
544 #
545 #     2) git branch: Used to install an lftools version from a specific branch.
546 #                    To use this set the variables as follows:
547 #                          LFTOOLS_MODE=git
548 #                          LFTOOLS_REFSPEC=master
549 #
550 #     3) release : The intended use case and default setting.
551 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
552
553 LFTOOLS_MODE=release  # release | git | gerrit
554 LFTOOLS_REFSPEC=master
555
556 # Ensure we fail the job if any steps fail.
557 # DO NOT set -u as virtualenv's activate script has unbound variables
558 set -e -o pipefail
559
560 virtualenv --quiet &quot;/tmp/v/lftools&quot;
561 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
562 source &quot;/tmp/v/lftools/bin/activate&quot;
563 pip install --quiet --upgrade pip
564
565 case $LFTOOLS_MODE in
566     gerrit)
567         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
568         pushd /tmp/lftools
569         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
570         git checkout FETCH_HEAD
571         pip install --quiet --upgrade -r requirements.txt
572         pip install --quiet --upgrade -e .
573         popd
574         ;;
575
576     git)
577         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
578         ;;
579
580     release)
581         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
582             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
583         fi
584
585         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
586         ;;
587 esac
588
589 lftools --version
590
591 # pipdeptree prints out a lot of information because lftools pulls in many
592 # dependencies. Let's only print it if we want to debug.
593 # echo &quot;----&gt; Pip Dependency Tree&quot;
594 # pip install --quiet --upgrade pipdeptree
595 # pipdeptree
596
597 #!/bin/bash
598 # SPDX-License-Identifier: EPL-1.0
599 ##############################################################################
600 # Copyright (c) 2017 The Linux Foundation and others.
601 #
602 # All rights reserved. This program and the accompanying materials
603 # are made available under the terms of the Eclipse Public License v1.0
604 # which accompanies this distribution, and is available at
605 # http://www.eclipse.org/legal/epl-v10.html
606 ##############################################################################
607 echo &quot;---&gt; logs-deploy.sh&quot;
608
609 # Ensure we fail the job if any steps fail.
610 set -eu -o pipefail
611
612 set -x  # Trace commands for this script to make debugging easier.
613
614 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
615 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
616
617 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
618 then
619     set +x # Disable trace since we no longer need it
620
621     echo &quot;WARNING: Logging server not set&quot;
622 else
623     NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
624     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
625     BUILD_URL=&quot;${BUILD_URL}&quot;
626
627     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
628     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
629
630     set +x  # Disable trace since we no longer need it.
631
632     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
633 fi
634 </command>
635         </hudson.tasks.Shell>
636         <hudson.tasks.Shell>
637           <command>#!/bin/bash
638 # SPDX-License-Identifier: EPL-1.0
639 ##############################################################################
640 # Copyright (c) 2017 The Linux Foundation and others.
641 #
642 # All rights reserved. This program and the accompanying materials
643 # are made available under the terms of the Eclipse Public License v1.0
644 # which accompanies this distribution, and is available at
645 # http://www.eclipse.org/legal/epl-v10.html
646 ##############################################################################
647
648 # Clear log credential files
649 rm &quot;$SETTINGS_FILE&quot;
650 rm ~/.netrc
651 </command>
652         </hudson.tasks.Shell>
653         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
654           <regexp>^Build logs: .*</regexp>
655         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
656       </buildSteps>
657       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
658       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
659       <markBuildUnstable>false</markBuildUnstable>
660     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
661     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
662       <patterns>
663         <hudson.plugins.ws__cleanup.Pattern>
664           <pattern>**/*.jenkins-trigger</pattern>
665           <type>EXCLUDE</type>
666         </hudson.plugins.ws__cleanup.Pattern>
667       </patterns>
668       <deleteDirs>false</deleteDirs>
669       <cleanupMatrixParent>false</cleanupMatrixParent>
670       <externalDelete/>
671       <cleanWhenSuccess>true</cleanWhenSuccess>
672       <cleanWhenUnstable>true</cleanWhenUnstable>
673       <cleanWhenFailure>true</cleanWhenFailure>
674       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
675       <cleanWhenAborted>true</cleanWhenAborted>
676       <notFailBuild>true</notFailBuild>
677     </hudson.plugins.ws__cleanup.WsCleanup>
678   </publishers>
679   <buildWrappers>
680     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
681     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
682       <timeoutMinutes>45</timeoutMinutes>
683       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
684       <failBuild>true</failBuild>
685       <writingDescription>false</writingDescription>
686       <timeoutPercentage>0</timeoutPercentage>
687       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
688       <timeoutType>absolute</timeoutType>
689     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
690     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
691     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
692       <user>test-credential</user>
693     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
694     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
695   </buildWrappers>
696 </project>