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