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