f5e708cd0e91b0c9b942b747c0e6118d1bf64c26
[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 metadata_files=($(diff -s -r &quot;$m2repo_dir&quot; &quot;$WORKSPACE/m2repo-backup&quot; \
453     | grep 'Files .* and .* are identical' | awk '{print $2}'))
454 set -e  # Re-enable.
455
456 set +u  # $metadata_files could be unbound if project is new.
457 if [ -n &quot;${metadata_files[*]}&quot; ]; then
458     for i in &quot;${metadata_files[@]}&quot;; do
459         rm &quot;$i&quot;*
460     done
461 fi
462 set -u  # Re-enable.
463
464 find &quot;$m2repo_dir&quot; -type d -empty -delete
465
466 lftools deploy nexus -s &quot;$nexus_repo_url&quot; &quot;$m2repo_dir&quot;
467 </command>
468     </hudson.tasks.Shell>
469     <hudson.tasks.Shell>
470       <command>#!/bin/bash
471 set +e  # DO NOT cause build failure if any of the rm calls fail.
472
473 rm &quot;$GLOBAL_SETTINGS_FILE&quot; &quot;$SETTINGS_FILE&quot;
474
475 # In some cases we use the lf-provide-maven-settings macro to produce
476 # a &quot;$HOME/.netrc&quot; file containing credentials. Remove that file here
477 # too if it exists.
478 rm &quot;$HOME/.netrc&quot;
479
480 # DO NOT fail build if any of the above lines fail.
481 exit 0
482 </command>
483     </hudson.tasks.Shell>
484   </builders>
485   <publishers>
486     <hudson.plugins.findbugs.FindBugsPublisher plugin="findbugs">
487       <isRankActivated>false</isRankActivated>
488       <includePattern/>
489       <excludePattern/>
490       <healthy/>
491       <unHealthy/>
492       <thresholdLimit>low</thresholdLimit>
493       <pluginName>[FINDBUGS] </pluginName>
494       <defaultEncoding/>
495       <canRunOnFailed>false</canRunOnFailed>
496       <useStableBuildAsReference>false</useStableBuildAsReference>
497       <usePreviousBuildAsReference>false</usePreviousBuildAsReference>
498       <useDeltaValues>false</useDeltaValues>
499       <thresholds>
500         <unstableTotalAll/>
501         <unstableTotalHigh/>
502         <unstableTotalNormal/>
503         <unstableTotalLow/>
504         <failedTotalAll/>
505         <failedTotalHigh/>
506         <failedTotalNormal/>
507         <failedTotalLow/>
508       </thresholds>
509       <shouldDetectModules>false</shouldDetectModules>
510       <dontComputeNew>true</dontComputeNew>
511       <doNotResolveRelativePaths>false</doNotResolveRelativePaths>
512       <pattern/>
513     </hudson.plugins.findbugs.FindBugsPublisher>
514     <hudson.plugins.jacoco.JacocoPublisher>
515       <execPattern>**/**.exec</execPattern>
516       <classPattern>**/classes</classPattern>
517       <sourcePattern>**/src/main/java</sourcePattern>
518       <changeBuildStatus/>
519       <inclusionPattern/>
520       <exclusionPattern>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</exclusionPattern>
521       <maximumBranchCoverage>10</maximumBranchCoverage>
522       <minimumBranchCoverage>20</minimumBranchCoverage>
523       <maximumMethodCoverage>50</maximumMethodCoverage>
524       <minimumMethodCoverage>40</minimumMethodCoverage>
525     </hudson.plugins.jacoco.JacocoPublisher>
526     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
527       <buildSteps>
528         <hudson.tasks.Shell>
529           <command>#!/bin/bash
530 # SPDX-License-Identifier: EPL-1.0
531 ##############################################################################
532 # Copyright (c) 2017 The Linux Foundation and others.
533 #
534 # All rights reserved. This program and the accompanying materials
535 # are made available under the terms of the Eclipse Public License v1.0
536 # which accompanies this distribution, and is available at
537 # http://www.eclipse.org/legal/epl-v10.html
538 ##############################################################################
539 echo &quot;---&gt; sysstat.sh&quot;
540 set +e  # DON'T fail build if script fails.
541
542 OS=$(facter operatingsystem)
543 case &quot;$OS&quot; in
544     Ubuntu)
545         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
546
547         # Dont run the script when systat is not enabled by default
548         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
549             exit 0
550         fi
551     ;;
552     CentOS|RedHat)
553         SYSSTAT_PATH=&quot;/var/log/sa&quot;
554     ;;
555     *)
556         # nothing to do
557         exit 0
558     ;;
559 esac
560
561 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
562 mkdir -p &quot;$SAR_DIR&quot;
563 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
564 # convert sar data to ascii format
565 while IFS=&quot;&quot; read -r sarfilenum
566 do
567     [ -f &quot;$sarfilenum&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$sarfilenum&quot; &gt; &quot;$SAR_DIR/sar${sarfilenum//[!0-9]/}&quot;
568 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
569
570 # DON'T fail build if script fails.
571 exit 0
572 </command>
573         </hudson.tasks.Shell>
574         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
575           <managedFiles>
576             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
577               <fileId>jenkins-log-archives-settings</fileId>
578               <targetLocation/>
579               <variable>SETTINGS_FILE</variable>
580             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
581           </managedFiles>
582         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
583         <EnvInjectBuilder>
584           <info>
585             <propertiesContent>SERVER_ID=logs</propertiesContent>
586           </info>
587         </EnvInjectBuilder>
588         <hudson.tasks.Shell>
589           <command>#!/bin/bash
590 # SPDX-License-Identifier: EPL-1.0
591 ##############################################################################
592 # Copyright (c) 2017 The Linux Foundation and others.
593 #
594 # All rights reserved. This program and the accompanying materials
595 # are made available under the terms of the Eclipse Public License v1.0
596 # which accompanies this distribution, and is available at
597 # http://www.eclipse.org/legal/epl-v10.html
598 ##############################################################################
599 echo &quot;---&gt; create-netrc.sh&quot;
600
601 # Ensure we fail the job if any steps fail.
602 set -eu -o pipefail
603
604 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
605 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
606     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
607     -v x:username -o &quot;:&quot; -v x:password \
608     &quot;$SETTINGS_FILE&quot;)
609
610 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
611 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
612 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
613
614 echo &quot;machine ${machine%:*} login $user password $pass&quot; &gt; ~/.netrc
615 </command>
616         </hudson.tasks.Shell>
617         <hudson.tasks.Shell>
618           <command>#!/bin/bash
619 # SPDX-License-Identifier: EPL-1.0
620 ##############################################################################
621 # Copyright (c) 2017 The Linux Foundation and others.
622 #
623 # All rights reserved. This program and the accompanying materials
624 # are made available under the terms of the Eclipse Public License v1.0
625 # which accompanies this distribution, and is available at
626 # http://www.eclipse.org/legal/epl-v10.html
627 ##############################################################################
628 echo &quot;---&gt; lftools-install.sh&quot;
629
630 # Script to install lftools via a version passed in via lf-infra-parameters
631 #
632 # Required parameters:
633 #
634 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
635 #                      set to a strict version number like '1.2.3' or using
636 #                      PEP-440 definitions.
637 #
638 #                      Examples:
639 #                          &lt;1.0.0
640 #                          &gt;=1.0.0,&lt;2.0.0
641 #
642 # By default a released version of lftools should always be used.
643 # The purpose of the 2 variables below is so that lftools devs can test
644 # unreleased versions of lftools. There are 2 methods to install a dev version
645 # of lftools:
646 #
647 #     1) gerrit patch: Used to test a patch that has not yet been merged.
648 #                      To do this set something like this:
649 #                          LFTOOLS_MODE=gerrit
650 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
651 #
652 #     2) git branch: Used to install an lftools version from a specific branch.
653 #                    To use this set the variables as follows:
654 #                          LFTOOLS_MODE=git
655 #                          LFTOOLS_REFSPEC=master
656 #
657 #     3) release : The intended use case and default setting.
658 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
659
660 LFTOOLS_MODE=release  # release | git | gerrit
661 LFTOOLS_REFSPEC=master
662
663 # Ensure we fail the job if any steps fail.
664 # DO NOT set -u as virtualenv's activate script has unbound variables
665 set -e -o pipefail
666
667 virtualenv --quiet &quot;/tmp/v/lftools&quot;
668 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
669 source &quot;/tmp/v/lftools/bin/activate&quot;
670 pip install --quiet --upgrade pip
671
672 case $LFTOOLS_MODE in
673     gerrit)
674         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
675         pushd /tmp/lftools
676         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
677         git checkout FETCH_HEAD
678         pip install --quiet --upgrade -r requirements.txt
679         pip install --quiet --upgrade -e .
680         popd
681         ;;
682
683     git)
684         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
685         ;;
686
687     release)
688         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
689             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
690         fi
691
692         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
693         ;;
694 esac
695
696 lftools --version
697
698 # pipdeptree prints out a lot of information because lftools pulls in many
699 # dependencies. Let's only print it if we want to debug.
700 # echo &quot;----&gt; Pip Dependency Tree&quot;
701 # pip install --quiet --upgrade pipdeptree
702 # pipdeptree
703
704 #!/bin/bash
705 # SPDX-License-Identifier: EPL-1.0
706 ##############################################################################
707 # Copyright (c) 2017 The Linux Foundation and others.
708 #
709 # All rights reserved. This program and the accompanying materials
710 # are made available under the terms of the Eclipse Public License v1.0
711 # which accompanies this distribution, and is available at
712 # http://www.eclipse.org/legal/epl-v10.html
713 ##############################################################################
714 echo &quot;---&gt; logs-deploy.sh&quot;
715
716 # Ensure we fail the job if any steps fail.
717 set -eu -o pipefail
718
719 set -x  # Trace commands for this script to make debugging easier.
720
721 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
722 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
723
724 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
725 then
726     set +x # Disable trace since we no longer need it
727
728     echo &quot;WARNING: Logging server not set&quot;
729 else
730     NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
731     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
732     BUILD_URL=&quot;${BUILD_URL}&quot;
733
734     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
735     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
736
737     set +x  # Disable trace since we no longer need it.
738
739     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
740 fi
741 </command>
742         </hudson.tasks.Shell>
743         <hudson.tasks.Shell>
744           <command>#!/bin/bash
745 # SPDX-License-Identifier: EPL-1.0
746 ##############################################################################
747 # Copyright (c) 2017 The Linux Foundation and others.
748 #
749 # All rights reserved. This program and the accompanying materials
750 # are made available under the terms of the Eclipse Public License v1.0
751 # which accompanies this distribution, and is available at
752 # http://www.eclipse.org/legal/epl-v10.html
753 ##############################################################################
754
755 # Clear log credential files
756 rm &quot;$SETTINGS_FILE&quot;
757 rm ~/.netrc
758 </command>
759         </hudson.tasks.Shell>
760         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
761           <regexp>^Build logs: .*</regexp>
762         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
763       </buildSteps>
764       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
765       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
766       <markBuildUnstable>false</markBuildUnstable>
767     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
768     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
769       <patterns>
770         <hudson.plugins.ws__cleanup.Pattern>
771           <pattern>**/*.jenkins-trigger</pattern>
772           <type>EXCLUDE</type>
773         </hudson.plugins.ws__cleanup.Pattern>
774       </patterns>
775       <deleteDirs>false</deleteDirs>
776       <cleanupMatrixParent>false</cleanupMatrixParent>
777       <externalDelete/>
778       <cleanWhenSuccess>true</cleanWhenSuccess>
779       <cleanWhenUnstable>true</cleanWhenUnstable>
780       <cleanWhenFailure>true</cleanWhenFailure>
781       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
782       <cleanWhenAborted>true</cleanWhenAborted>
783       <notFailBuild>true</notFailBuild>
784     </hudson.plugins.ws__cleanup.WsCleanup>
785     <hudson.plugins.parameterizedtrigger.BuildTrigger>
786       <configs/>
787     </hudson.plugins.parameterizedtrigger.BuildTrigger>
788   </publishers>
789   <buildWrappers>
790     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
791     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
792       <timeoutMinutes>30</timeoutMinutes>
793       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
794       <failBuild>true</failBuild>
795       <writingDescription>false</writingDescription>
796       <timeoutPercentage>0</timeoutPercentage>
797       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
798       <timeoutType>absolute</timeoutType>
799     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
800     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
801     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
802       <user>test-credential</user>
803     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
804     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
805     <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
806       <managedFiles>
807         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
808           <fileId>npmrc</fileId>
809           <targetLocation>$HOME/.npmrc</targetLocation>
810           <variable/>
811         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
812       </managedFiles>
813     </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
814   </buildWrappers>
815 </project>