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