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