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