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