Fix ShellCheck v0.4.7 lint issues
[releng/global-jjb.git] / .jjb-test / expected-xml / gerrit-maven-maven-merge-master
1 <?xml version="1.0" encoding="utf-8"?>
2 <project>
3   <jdk>openjdk8</jdk>
4   <actions/>
5   <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
6   <keepDependencies>false</keepDependencies>
7   <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
8   <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
9   <concurrentBuild>false</concurrentBuild>
10   <assignedNode>build-vm</assignedNode>
11   <canRoam>false</canRoam>
12   <properties>
13     <jenkins.model.BuildDiscarderProperty>
14       <strategy class="hudson.tasks.LogRotator">
15         <daysToKeep>30</daysToKeep>
16         <numToKeep>-1</numToKeep>
17         <artifactDaysToKeep>-1</artifactDaysToKeep>
18         <artifactNumToKeep>0</artifactNumToKeep>
19       </strategy>
20     </jenkins.model.BuildDiscarderProperty>
21     <hudson.model.ParametersDefinitionProperty>
22       <parameterDefinitions>
23         <hudson.model.StringParameterDefinition>
24           <name>PROJECT</name>
25           <description>Parameter to identify a Gerrit project. This is typically the
26 project repo path as exists in Gerrit.
27 For example: ofextensions/circuitsw
28 </description>
29           <defaultValue>releng/ciman</defaultValue>
30         </hudson.model.StringParameterDefinition>
31         <hudson.model.StringParameterDefinition>
32           <name>STREAM</name>
33           <description>Stream is often set to the same name as 'branch' but can
34 sometimes be used as a name representing a project's release code
35 name.
36 </description>
37           <defaultValue>master</defaultValue>
38         </hudson.model.StringParameterDefinition>
39         <hudson.model.StringParameterDefinition>
40           <name>GERRIT_PROJECT</name>
41           <description>Parameter to identify Gerrit project. This is typically the
42 project repo path as exists in Gerrit.
43 For example: ofextensions/circuitsw
44
45 Note that Gerrit will override this parameter automatically if a
46 job is triggered by Gerrit.
47 </description>
48           <defaultValue>releng/ciman</defaultValue>
49         </hudson.model.StringParameterDefinition>
50         <hudson.model.StringParameterDefinition>
51           <name>GERRIT_BRANCH</name>
52           <description>Parameter to identify a Gerrit branch.
53
54 Note that Gerrit will override this parameter automatically if a
55 job is triggered by Gerrit.
56 </description>
57           <defaultValue>master</defaultValue>
58         </hudson.model.StringParameterDefinition>
59         <hudson.model.StringParameterDefinition>
60           <name>GERRIT_REFSPEC</name>
61           <description>Parameter to identify a refspec when pulling from Gerrit.
62
63 Note that Gerrit will override this parameter automatically if a
64 job is triggered by Gerrit.
65 </description>
66           <defaultValue>refs/heads/master</defaultValue>
67         </hudson.model.StringParameterDefinition>
68         <hudson.model.StringParameterDefinition>
69           <name>LFTOOLS_VERSION</name>
70           <description>Version of lftools to install. Can be a specific version like
71 '0.6.0' or a PEP-440 definition.
72 https://www.python.org/dev/peps/pep-0440/
73 For example '&lt;1.0.0' or '&gt;=1.0.0,&lt;2.0.0'.
74 </description>
75           <defaultValue>&lt;1.0.0</defaultValue>
76         </hudson.model.StringParameterDefinition>
77         <hudson.model.StringParameterDefinition>
78           <name>M2_HOME</name>
79           <description>Maven selector to be used by shell scripts</description>
80           <defaultValue>/w/tools/hudson.tasks.Maven_MavenInstallation/mvn33</defaultValue>
81         </hudson.model.StringParameterDefinition>
82         <hudson.model.StringParameterDefinition>
83           <name>MAVEN_OPTS</name>
84           <description>Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
85 </description>
86           <defaultValue/>
87         </hudson.model.StringParameterDefinition>
88         <hudson.model.StringParameterDefinition>
89           <name>MAVEN_PARAMS</name>
90           <description>Maven parameters to pass to the mvn command.
91 </description>
92           <defaultValue>-Dmerge</defaultValue>
93         </hudson.model.StringParameterDefinition>
94         <hudson.model.StringParameterDefinition>
95           <name>MVN</name>
96           <description>Maven selector to be used by shell scripts</description>
97           <defaultValue>/w/tools/hudson.tasks.Maven_MavenInstallation/mvn33/bin/mvn</defaultValue>
98         </hudson.model.StringParameterDefinition>
99         <hudson.model.StringParameterDefinition>
100           <name>STAGING_PROFILE_ID</name>
101           <description>Nexus staging profile ID.
102 </description>
103           <defaultValue>uuddlrlrba</defaultValue>
104         </hudson.model.StringParameterDefinition>
105         <hudson.model.StringParameterDefinition>
106           <name>ARCHIVE_ARTIFACTS</name>
107           <description>Artifacts to archive to the logs server.</description>
108           <defaultValue/>
109         </hudson.model.StringParameterDefinition>
110       </parameterDefinitions>
111     </hudson.model.ParametersDefinitionProperty>
112   </properties>
113   <scm class="hudson.plugins.git.GitSCM">
114     <configVersion>2</configVersion>
115     <userRemoteConfigs>
116       <hudson.plugins.git.UserRemoteConfig>
117         <name>origin</name>
118         <refspec>$GERRIT_REFSPEC</refspec>
119         <url>$GIT_URL/$PROJECT</url>
120         <credentialsId>test-credential</credentialsId>
121       </hudson.plugins.git.UserRemoteConfig>
122     </userRemoteConfigs>
123     <branches>
124       <hudson.plugins.git.BranchSpec>
125         <name>refs/heads/$GERRIT_BRANCH</name>
126       </hudson.plugins.git.BranchSpec>
127     </branches>
128     <excludedUsers/>
129     <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
130     <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
131     <authorOrCommitter>false</authorOrCommitter>
132     <wipeOutWorkspace>true</wipeOutWorkspace>
133     <pruneBranches>false</pruneBranches>
134     <remotePoll>false</remotePoll>
135     <gitTool>Default</gitTool>
136     <submoduleCfg class="list"/>
137     <relativeTargetDir/>
138     <reference/>
139     <gitConfigName/>
140     <gitConfigEmail/>
141     <skipTag>true</skipTag>
142     <scmName/>
143     <useShallowClone>false</useShallowClone>
144     <ignoreNotifyCommit>false</ignoreNotifyCommit>
145     <extensions>
146       <hudson.plugins.git.extensions.impl.SubmoduleOption>
147         <disableSubmodules>false</disableSubmodules>
148         <recursiveSubmodules>true</recursiveSubmodules>
149         <trackingSubmodules>false</trackingSubmodules>
150         <reference/>
151         <timeout>10</timeout>
152       </hudson.plugins.git.extensions.impl.SubmoduleOption>
153       <hudson.plugins.git.extensions.impl.WipeWorkspace/>
154     </extensions>
155   </scm>
156   <triggers class="vector">
157     <hudson.triggers.TimerTrigger>
158       <spec>H H * * 0</spec>
159     </hudson.triggers.TimerTrigger>
160     <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
161       <spec/>
162       <gerritProjects>
163         <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
164           <compareType>ANT</compareType>
165           <pattern>releng/ciman</pattern>
166           <branches>
167             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
168               <compareType>ANT</compareType>
169               <pattern>**/master</pattern>
170             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
171           </branches>
172           <filePaths>
173             <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
174               <compareType>ANT</compareType>
175               <pattern>**</pattern>
176             </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
177           </filePaths>
178           <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
179         </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
180       </gerritProjects>
181       <skipVote>
182         <onSuccessful>false</onSuccessful>
183         <onFailed>false</onFailed>
184         <onUnstable>false</onUnstable>
185         <onNotBuilt>false</onNotBuilt>
186       </skipVote>
187       <silentMode>false</silentMode>
188       <silentStartMode>false</silentStartMode>
189       <escapeQuotes>true</escapeQuotes>
190       <noNameAndEmailParameters>false</noNameAndEmailParameters>
191       <readableMessage>false</readableMessage>
192       <dependencyJobsNames/>
193       <notificationLevel/>
194       <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
195       <triggerConfigURL/>
196       <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
197       <triggerOnEvents>
198         <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginChangeMergedEvent/>
199         <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
200           <commentAddedCommentContains>remerge$</commentAddedCommentContains>
201         </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
202       </triggerOnEvents>
203       <buildStartMessage/>
204       <buildFailureMessage/>
205       <buildSuccessfulMessage/>
206       <buildUnstableMessage/>
207       <buildNotBuiltMessage/>
208       <buildUnsuccessfulFilepath/>
209       <customUrl/>
210       <serverName>test-server</serverName>
211     </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
212   </triggers>
213   <builders>
214     <hudson.tasks.Shell>
215       <command>mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes</command>
216     </hudson.tasks.Shell>
217     <hudson.tasks.Shell>
218       <command>echo &quot;quiet=on&quot; &gt; &quot;$HOME/.wgetrc&quot;</command>
219     </hudson.tasks.Shell>
220     <hudson.tasks.Maven>
221       <targets>--version</targets>
222       <properties/>
223       <mavenName>mvn33</mavenName>
224       <usePrivateRepository>false</usePrivateRepository>
225       <settings class="jenkins.mvn.DefaultSettingsProvider"/>
226       <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
227     </hudson.tasks.Maven>
228     <hudson.tasks.Shell>
229       <command>rm &quot;$HOME/.wgetrc&quot;</command>
230     </hudson.tasks.Shell>
231     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
232       <managedFiles>
233         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
234           <fileId>global-settings</fileId>
235           <targetLocation/>
236           <variable>GLOBAL_SETTINGS_FILE</variable>
237         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
238         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
239           <fileId>gerrit-maven-project-settings</fileId>
240           <targetLocation/>
241           <variable>SETTINGS_FILE</variable>
242         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
243       </managedFiles>
244     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
245     <EnvInjectBuilder>
246       <info>
247         <propertiesContent>SERVER_ID=fakeproject-snapshots</propertiesContent>
248       </info>
249     </EnvInjectBuilder>
250     <hudson.tasks.Shell>
251       <command>#!/bin/bash
252 # SPDX-License-Identifier: EPL-1.0
253 ##############################################################################
254 # Copyright (c) 2017 The Linux Foundation and others.
255 #
256 # All rights reserved. This program and the accompanying materials
257 # are made available under the terms of the Eclipse Public License v1.0
258 # which accompanies this distribution, and is available at
259 # http://www.eclipse.org/legal/epl-v10.html
260 ##############################################################################
261 echo &quot;---&gt; create-netrc.sh&quot;
262
263 # Ensure we fail the job if any steps fail.
264 set -eu -o pipefail
265
266 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
267 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
268     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
269     -v x:username -o &quot;:&quot; -v x:password \
270     &quot;$SETTINGS_FILE&quot;)
271
272 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
273 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
274 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
275
276 echo &quot;machine ${machine%:*} login $user password $pass&quot; &gt; ~/.netrc
277 </command>
278     </hudson.tasks.Shell>
279     <EnvInjectBuilder>
280       <info>
281         <propertiesContent>NEXUS_CUT_DIRS=6
282 NEXUS_REPO=fakeproject-snapshots
283 </propertiesContent>
284       </info>
285     </EnvInjectBuilder>
286     <hudson.tasks.Shell>
287       <command>#!/bin/bash
288 # SPDX-License-Identifier: EPL-1.0
289 ##############################################################################
290 # Copyright (c) 2017 The Linux Foundation and others.
291 #
292 # All rights reserved. This program and the accompanying materials
293 # are made available under the terms of the Eclipse Public License v1.0
294 # which accompanies this distribution, and is available at
295 # http://www.eclipse.org/legal/epl-v10.html
296 ##############################################################################
297 echo &quot;---&gt; lftools-install.sh&quot;
298
299 # Script to install lftools via a version passed in via lf-infra-parameters
300 #
301 # Required parameters:
302 #
303 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
304 #                      set to a strict version number like '1.2.3' or using
305 #                      PEP-440 definitions.
306 #
307 #                      Examples:
308 #                          &lt;1.0.0
309 #                          &gt;=1.0.0,&lt;2.0.0
310 #
311 # By default a released version of lftools should always be used.
312 # The purpose of the 2 variables below is so that lftools devs can test
313 # unreleased versions of lftools. There are 2 methods to install a dev version
314 # of lftools:
315 #
316 #     1) gerrit patch: Used to test a patch that has not yet been merged.
317 #                      To do this set something like this:
318 #                          LFTOOLS_MODE=gerrit
319 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
320 #
321 #     2) git branch: Used to install an lftools version from a specific branch.
322 #                    To use this set the variables as follows:
323 #                          LFTOOLS_MODE=git
324 #                          LFTOOLS_REFSPEC=master
325 #
326 #     3) release : The intended use case and default setting.
327 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
328
329 LFTOOLS_MODE=release  # release | git | gerrit
330 LFTOOLS_REFSPEC=master
331
332 # Ensure we fail the job if any steps fail.
333 # DO NOT set -u as virtualenv's activate script has unbound variables
334 set -e -o pipefail
335
336 virtualenv --quiet &quot;/tmp/v/lftools&quot;
337 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
338 source &quot;/tmp/v/lftools/bin/activate&quot;
339 pip install --quiet --upgrade pip
340
341 case $LFTOOLS_MODE in
342     gerrit)
343         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
344         pushd /tmp/lftools
345         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
346         git checkout FETCH_HEAD
347         pip install --quiet --upgrade -r requirements.txt
348         pip install --quiet --upgrade -e .
349         popd
350         ;;
351
352     git)
353         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
354         ;;
355
356     release)
357         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
358             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
359         fi
360
361         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
362         ;;
363 esac
364
365 lftools --version
366
367 # pipdeptree prints out a lot of information because lftools pulls in many
368 # dependencies. Let's only print it if we want to debug.
369 # echo &quot;----&gt; Pip Dependency Tree&quot;
370 # pip install --quiet --upgrade pipdeptree
371 # pipdeptree
372
373 #!/bin/bash
374 # SPDX-License-Identifier: EPL-1.0
375 ##############################################################################
376 # Copyright (c) 2017 The Linux Foundation and others.
377 #
378 # All rights reserved. This program and the accompanying materials
379 # are made available under the terms of the Eclipse Public License v1.0
380 # which accompanies this distribution, and is available at
381 # http://www.eclipse.org/legal/epl-v10.html
382 ##############################################################################
383
384 # This file contains a list of variables that are generally useful in many
385 # scripts. It is meant to be sourced in other scripts so that the variables can
386 # be called.
387
388 MAVEN_OPTIONS=&quot;$(echo --show-version \
389     --batch-mode \
390     -Djenkins \
391     -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
392     -Dmaven.repo.local=/tmp/r \
393     -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r)&quot;
394 echo &quot;$MAVEN_OPTIONS&quot;
395
396 #!/bin/bash
397 # SPDX-License-Identifier: EPL-1.0
398 ##############################################################################
399 # Copyright (c) 2017 The Linux Foundation and others.
400 #
401 # All rights reserved. This program and the accompanying materials
402 # are made available under the terms of the Eclipse Public License v1.0
403 # which accompanies this distribution, and is available at
404 # http://www.eclipse.org/legal/epl-v10.html
405 ##############################################################################
406
407 # Uses wget to fetch a project's maven-metadata.xml files from a Maven repository.
408
409 # Ensure we fail the job if any steps fail.
410 set -eu -o pipefail
411
412 project=$(xmlstarlet sel \
413     -N &quot;x=http://maven.apache.org/POM/4.0.0&quot; -t \
414     --if &quot;/x:project/x:groupId&quot; \
415       -v &quot;/x:project/x:groupId&quot; \
416     --elif &quot;/x:project/x:parent/x:groupId&quot; \
417       -v &quot;/x:project/x:parent/x:groupId&quot; \
418     --else -o &quot;&quot; pom.xml)
419 project_path=&quot;${project//.//}&quot;
420
421 mkdir -p &quot;$WORKSPACE/m2repo/$project_path&quot;
422 pushd &quot;$WORKSPACE/m2repo/$project_path&quot;
423     # Temporarily disable failing for wget
424     # If 404 happens we don't care because it might be a new project.
425     set +e
426     wget -nv --recursive \
427          --accept maven-metadata.xml \
428          -R &quot;index.html*&quot; \
429          --execute robots=off \
430          --no-parent \
431          --no-host-directories \
432          --cut-dirs=&quot;$NEXUS_CUT_DIRS&quot; \
433          &quot;$NEXUS_URL/content/repositories/$NEXUS_REPO/$project_path/&quot;
434     set -e  # Re-enable.
435 popd
436
437 # Backup metadata - Used later to find metadata files that have not been modified
438 mkdir -p &quot;$WORKSPACE/m2repo-backup&quot;
439 cp -a &quot;$WORKSPACE/m2repo/&quot;* &quot;$WORKSPACE/m2repo-backup&quot;
440
441 #!/bin/bash
442 # SPDX-License-Identifier: EPL-1.0
443 ##############################################################################
444 # Copyright (c) 2017 The Linux Foundation and others.
445 #
446 # All rights reserved. This program and the accompanying materials
447 # are made available under the terms of the Eclipse Public License v1.0
448 # which accompanies this distribution, and is available at
449 # http://www.eclipse.org/legal/epl-v10.html
450 ##############################################################################
451
452 # This script builds a Maven project and deploys it into a staging repo which
453 # can be used to deploy elsewhere later eg. Nexus staging / snapshot repos.
454
455 # DO NOT enable -u because $MAVEN_PARAMS and $MAVEN_OPTIONS could be unbound.
456 # Ensure we fail the job if any steps fail.
457 set -e -o pipefail
458 set +u
459
460 export MAVEN_OPTS
461
462 # Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
463 # shellcheck disable=SC2086
464 $MVN clean deploy \
465     --global-settings &quot;$GLOBAL_SETTINGS_FILE&quot; \
466     --settings &quot;$SETTINGS_FILE&quot; \
467     -DaltDeploymentRepository=staging::default::file:&quot;$WORKSPACE&quot;/m2repo \
468     $MAVEN_OPTIONS $MAVEN_PARAMS
469
470 #!/bin/bash
471 # SPDX-License-Identifier: EPL-1.0
472 ##############################################################################
473 # Copyright (c) 2017 The Linux Foundation and others.
474 #
475 # All rights reserved. This program and the accompanying materials
476 # are made available under the terms of the Eclipse Public License v1.0
477 # which accompanies this distribution, and is available at
478 # http://www.eclipse.org/legal/epl-v10.html
479 ##############################################################################
480 # Upload the snapshot files to a snapshot repo.
481 #
482 # Requires the existance of $WORKSPACE/m2repo and $WORKSPACE/m2repo-backup to
483 # compare if maven metadata files have changed. Unchanged files are then
484 # removed from $WORKSPACE/m2repo before uploading to the snapshot repo.
485
486 # Ensure we fail the job if any steps fail.
487 set -eu -o pipefail
488
489 m2repo_dir=&quot;$WORKSPACE/m2repo&quot;
490 nexus_repo_url=&quot;$NEXUS_URL/content/repositories/$NEXUS_REPO&quot;
491
492 # Remove metadata files that were not updated.
493 set +e  # Temporarily disable to run diff command.
494 IFS=&quot; &quot; read -r -a metadata_files &lt;&lt;&lt; &quot;$(diff -s -r &quot;$m2repo_dir&quot; &quot;$WORKSPACE/m2repo-backup&quot; \
495     | grep 'Files .* and .* are identical' \
496     | awk '{print $2}')&quot;
497 set -e  # Re-enable.
498
499 set +u  # $metadata_files could be unbound if project is new.
500 if [ -n &quot;${metadata_files[*]}&quot; ]; then
501     for i in &quot;${metadata_files[@]}&quot;; do
502         rm &quot;$i&quot;*
503     done
504 fi
505 set -u  # Re-enable.
506
507 find &quot;$m2repo_dir&quot; -type d -empty -delete
508
509 lftools deploy nexus -s &quot;$nexus_repo_url&quot; &quot;$m2repo_dir&quot;
510 </command>
511     </hudson.tasks.Shell>
512     <hudson.tasks.Shell>
513       <command>#!/bin/bash
514 set +e  # DO NOT cause build failure if any of the rm calls fail.
515
516 rm &quot;$GLOBAL_SETTINGS_FILE&quot; &quot;$SETTINGS_FILE&quot;
517
518 # In some cases we use the lf-provide-maven-settings macro to produce
519 # a &quot;$HOME/.netrc&quot; file containing credentials. Remove that file here
520 # too if it exists.
521 rm &quot;$HOME/.netrc&quot;
522
523 # DO NOT fail build if any of the above lines fail.
524 exit 0
525 </command>
526     </hudson.tasks.Shell>
527   </builders>
528   <publishers>
529     <hudson.plugins.findbugs.FindBugsPublisher plugin="findbugs">
530       <isRankActivated>false</isRankActivated>
531       <includePattern/>
532       <excludePattern/>
533       <healthy/>
534       <unHealthy/>
535       <thresholdLimit>low</thresholdLimit>
536       <pluginName>[FINDBUGS] </pluginName>
537       <defaultEncoding/>
538       <canRunOnFailed>false</canRunOnFailed>
539       <useStableBuildAsReference>false</useStableBuildAsReference>
540       <usePreviousBuildAsReference>false</usePreviousBuildAsReference>
541       <useDeltaValues>false</useDeltaValues>
542       <thresholds>
543         <unstableTotalAll/>
544         <unstableTotalHigh/>
545         <unstableTotalNormal/>
546         <unstableTotalLow/>
547         <failedTotalAll/>
548         <failedTotalHigh/>
549         <failedTotalNormal/>
550         <failedTotalLow/>
551       </thresholds>
552       <shouldDetectModules>false</shouldDetectModules>
553       <dontComputeNew>true</dontComputeNew>
554       <doNotResolveRelativePaths>false</doNotResolveRelativePaths>
555       <pattern/>
556     </hudson.plugins.findbugs.FindBugsPublisher>
557     <hudson.plugins.jacoco.JacocoPublisher>
558       <execPattern>**/**.exec</execPattern>
559       <classPattern>**/classes</classPattern>
560       <sourcePattern>**/src/main/java</sourcePattern>
561       <changeBuildStatus/>
562       <inclusionPattern/>
563       <exclusionPattern>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</exclusionPattern>
564       <maximumBranchCoverage>10</maximumBranchCoverage>
565       <minimumBranchCoverage>20</minimumBranchCoverage>
566       <maximumMethodCoverage>50</maximumMethodCoverage>
567       <minimumMethodCoverage>40</minimumMethodCoverage>
568     </hudson.plugins.jacoco.JacocoPublisher>
569     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
570       <buildSteps>
571         <hudson.tasks.Shell>
572           <command>#!/bin/bash
573 # SPDX-License-Identifier: EPL-1.0
574 ##############################################################################
575 # Copyright (c) 2017 The Linux Foundation and others.
576 #
577 # All rights reserved. This program and the accompanying materials
578 # are made available under the terms of the Eclipse Public License v1.0
579 # which accompanies this distribution, and is available at
580 # http://www.eclipse.org/legal/epl-v10.html
581 ##############################################################################
582 echo &quot;---&gt; sysstat.sh&quot;
583 set +e  # DON'T fail build if script fails.
584
585 OS=$(facter operatingsystem)
586 case &quot;$OS&quot; in
587     Ubuntu)
588         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
589
590         # Dont run the script when systat is not enabled by default
591         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
592             exit 0
593         fi
594     ;;
595     CentOS|RedHat)
596         SYSSTAT_PATH=&quot;/var/log/sa&quot;
597     ;;
598     *)
599         # nothing to do
600         exit 0
601     ;;
602 esac
603
604 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
605 mkdir -p &quot;$SAR_DIR&quot;
606 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
607 # convert sar data to ascii format
608 while IFS=&quot;&quot; read -r sarfilenum
609 do
610     [ -f &quot;$sarfilenum&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$sarfilenum&quot; &gt; &quot;$SAR_DIR/sar${sarfilenum//[!0-9]/}&quot;
611 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
612
613 # DON'T fail build if script fails.
614 exit 0
615 </command>
616         </hudson.tasks.Shell>
617         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
618           <managedFiles>
619             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
620               <fileId>jenkins-log-archives-settings</fileId>
621               <targetLocation/>
622               <variable>SETTINGS_FILE</variable>
623             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
624           </managedFiles>
625         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
626         <EnvInjectBuilder>
627           <info>
628             <propertiesContent>SERVER_ID=logs</propertiesContent>
629           </info>
630         </EnvInjectBuilder>
631         <hudson.tasks.Shell>
632           <command>#!/bin/bash
633 # SPDX-License-Identifier: EPL-1.0
634 ##############################################################################
635 # Copyright (c) 2017 The Linux Foundation and others.
636 #
637 # All rights reserved. This program and the accompanying materials
638 # are made available under the terms of the Eclipse Public License v1.0
639 # which accompanies this distribution, and is available at
640 # http://www.eclipse.org/legal/epl-v10.html
641 ##############################################################################
642 echo &quot;---&gt; create-netrc.sh&quot;
643
644 # Ensure we fail the job if any steps fail.
645 set -eu -o pipefail
646
647 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
648 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
649     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
650     -v x:username -o &quot;:&quot; -v x:password \
651     &quot;$SETTINGS_FILE&quot;)
652
653 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
654 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
655 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
656
657 echo &quot;machine ${machine%:*} login $user password $pass&quot; &gt; ~/.netrc
658 </command>
659         </hudson.tasks.Shell>
660         <hudson.tasks.Shell>
661           <command>#!/bin/bash
662 # SPDX-License-Identifier: EPL-1.0
663 ##############################################################################
664 # Copyright (c) 2017 The Linux Foundation and others.
665 #
666 # All rights reserved. This program and the accompanying materials
667 # are made available under the terms of the Eclipse Public License v1.0
668 # which accompanies this distribution, and is available at
669 # http://www.eclipse.org/legal/epl-v10.html
670 ##############################################################################
671 echo &quot;---&gt; lftools-install.sh&quot;
672
673 # Script to install lftools via a version passed in via lf-infra-parameters
674 #
675 # Required parameters:
676 #
677 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
678 #                      set to a strict version number like '1.2.3' or using
679 #                      PEP-440 definitions.
680 #
681 #                      Examples:
682 #                          &lt;1.0.0
683 #                          &gt;=1.0.0,&lt;2.0.0
684 #
685 # By default a released version of lftools should always be used.
686 # The purpose of the 2 variables below is so that lftools devs can test
687 # unreleased versions of lftools. There are 2 methods to install a dev version
688 # of lftools:
689 #
690 #     1) gerrit patch: Used to test a patch that has not yet been merged.
691 #                      To do this set something like this:
692 #                          LFTOOLS_MODE=gerrit
693 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
694 #
695 #     2) git branch: Used to install an lftools version from a specific branch.
696 #                    To use this set the variables as follows:
697 #                          LFTOOLS_MODE=git
698 #                          LFTOOLS_REFSPEC=master
699 #
700 #     3) release : The intended use case and default setting.
701 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
702
703 LFTOOLS_MODE=release  # release | git | gerrit
704 LFTOOLS_REFSPEC=master
705
706 # Ensure we fail the job if any steps fail.
707 # DO NOT set -u as virtualenv's activate script has unbound variables
708 set -e -o pipefail
709
710 virtualenv --quiet &quot;/tmp/v/lftools&quot;
711 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
712 source &quot;/tmp/v/lftools/bin/activate&quot;
713 pip install --quiet --upgrade pip
714
715 case $LFTOOLS_MODE in
716     gerrit)
717         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
718         pushd /tmp/lftools
719         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
720         git checkout FETCH_HEAD
721         pip install --quiet --upgrade -r requirements.txt
722         pip install --quiet --upgrade -e .
723         popd
724         ;;
725
726     git)
727         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
728         ;;
729
730     release)
731         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
732             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
733         fi
734
735         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
736         ;;
737 esac
738
739 lftools --version
740
741 # pipdeptree prints out a lot of information because lftools pulls in many
742 # dependencies. Let's only print it if we want to debug.
743 # echo &quot;----&gt; Pip Dependency Tree&quot;
744 # pip install --quiet --upgrade pipdeptree
745 # pipdeptree
746
747 #!/bin/bash
748 # SPDX-License-Identifier: EPL-1.0
749 ##############################################################################
750 # Copyright (c) 2017 The Linux Foundation and others.
751 #
752 # All rights reserved. This program and the accompanying materials
753 # are made available under the terms of the Eclipse Public License v1.0
754 # which accompanies this distribution, and is available at
755 # http://www.eclipse.org/legal/epl-v10.html
756 ##############################################################################
757 echo &quot;---&gt; logs-deploy.sh&quot;
758
759 # Ensure we fail the job if any steps fail.
760 set -eu -o pipefail
761
762 set -x  # Trace commands for this script to make debugging easier.
763
764 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
765 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
766
767 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
768 then
769     set +x # Disable trace since we no longer need it
770
771     echo &quot;WARNING: Logging server not set&quot;
772 else
773     NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
774     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
775     BUILD_URL=&quot;${BUILD_URL}&quot;
776
777     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
778     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
779
780     set +x  # Disable trace since we no longer need it.
781
782     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
783 fi
784 </command>
785         </hudson.tasks.Shell>
786         <hudson.tasks.Shell>
787           <command>#!/bin/bash
788 # SPDX-License-Identifier: EPL-1.0
789 ##############################################################################
790 # Copyright (c) 2017 The Linux Foundation and others.
791 #
792 # All rights reserved. This program and the accompanying materials
793 # are made available under the terms of the Eclipse Public License v1.0
794 # which accompanies this distribution, and is available at
795 # http://www.eclipse.org/legal/epl-v10.html
796 ##############################################################################
797
798 # Clear log credential files
799 rm &quot;$SETTINGS_FILE&quot;
800 rm ~/.netrc
801 </command>
802         </hudson.tasks.Shell>
803         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
804           <regexp>^Build logs: .*</regexp>
805         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
806       </buildSteps>
807       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
808       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
809       <markBuildUnstable>false</markBuildUnstable>
810     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
811     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
812       <patterns>
813         <hudson.plugins.ws__cleanup.Pattern>
814           <pattern>**/*.jenkins-trigger</pattern>
815           <type>EXCLUDE</type>
816         </hudson.plugins.ws__cleanup.Pattern>
817       </patterns>
818       <deleteDirs>false</deleteDirs>
819       <cleanupMatrixParent>false</cleanupMatrixParent>
820       <externalDelete/>
821       <cleanWhenSuccess>true</cleanWhenSuccess>
822       <cleanWhenUnstable>true</cleanWhenUnstable>
823       <cleanWhenFailure>true</cleanWhenFailure>
824       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
825       <cleanWhenAborted>true</cleanWhenAborted>
826       <notFailBuild>true</notFailBuild>
827     </hudson.plugins.ws__cleanup.WsCleanup>
828     <hudson.plugins.parameterizedtrigger.BuildTrigger>
829       <configs/>
830     </hudson.plugins.parameterizedtrigger.BuildTrigger>
831   </publishers>
832   <buildWrappers>
833     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
834     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
835       <timeoutMinutes>30</timeoutMinutes>
836       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
837       <failBuild>true</failBuild>
838       <writingDescription>false</writingDescription>
839       <timeoutPercentage>0</timeoutPercentage>
840       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
841       <timeoutType>absolute</timeoutType>
842     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
843     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
844     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
845       <user>test-credential</user>
846     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
847     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
848     <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
849       <managedFiles>
850         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
851           <fileId>npmrc</fileId>
852           <targetLocation>$HOME/.npmrc</targetLocation>
853           <variable/>
854         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
855       </managedFiles>
856     </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
857   </buildWrappers>
858 </project>