169f1adaf90c405014b11c5d974971d894478e76
[releng/global-jjb.git] / .jjb-test / expected-xml / github-maven-maven-release-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/>
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>refs/heads/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     <hudson.triggers.TimerTrigger>
153       <spec/>
154     </hudson.triggers.TimerTrigger>
155     <org.jenkinsci.plugins.ghprb.GhprbTrigger>
156       <spec/>
157       <adminlist/>
158       <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
159       <whitelist/>
160       <orgslist/>
161       <cron/>
162       <triggerPhrase>^build release$</triggerPhrase>
163       <onlyTriggerPhrase>true</onlyTriggerPhrase>
164       <useGitHubHooks>true</useGitHubHooks>
165       <permitAll>true</permitAll>
166       <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
167       <extensions>
168         <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
169           <commitStatusContext>Maven Release</commitStatusContext>
170         </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
171       </extensions>
172     </org.jenkinsci.plugins.ghprb.GhprbTrigger>
173   </triggers>
174   <builders>
175     <hudson.tasks.Shell>
176       <command>mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes</command>
177     </hudson.tasks.Shell>
178     <hudson.tasks.Shell>
179       <command>echo &quot;quiet=on&quot; &gt; &quot;$HOME/.wgetrc&quot;</command>
180     </hudson.tasks.Shell>
181     <hudson.tasks.Maven>
182       <targets>--version</targets>
183       <properties/>
184       <mavenName>mvn33</mavenName>
185       <usePrivateRepository>false</usePrivateRepository>
186       <settings class="jenkins.mvn.DefaultSettingsProvider"/>
187       <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
188     </hudson.tasks.Maven>
189     <hudson.tasks.Shell>
190       <command>rm &quot;$HOME/.wgetrc&quot;</command>
191     </hudson.tasks.Shell>
192     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
193       <managedFiles>
194         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
195           <fileId>global-settings</fileId>
196           <targetLocation/>
197           <variable>GLOBAL_SETTINGS_FILE</variable>
198         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
199         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
200           <fileId>aproject-settings</fileId>
201           <targetLocation/>
202           <variable>SETTINGS_FILE</variable>
203         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
204       </managedFiles>
205     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
206     <EnvInjectBuilder>
207       <info>
208         <propertiesContent>SERVER_ID=project-staging</propertiesContent>
209       </info>
210     </EnvInjectBuilder>
211     <hudson.tasks.Shell>
212       <command>#!/bin/bash
213 # SPDX-License-Identifier: EPL-1.0
214 ##############################################################################
215 # Copyright (c) 2017 The Linux Foundation and others.
216 #
217 # All rights reserved. This program and the accompanying materials
218 # are made available under the terms of the Eclipse Public License v1.0
219 # which accompanies this distribution, and is available at
220 # http://www.eclipse.org/legal/epl-v10.html
221 ##############################################################################
222 echo &quot;---&gt; create-netrc.sh&quot;
223
224 # Ensure we fail the job if any steps fail.
225 set -eu -o pipefail
226
227 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
228 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
229     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
230     -v x:username -o &quot;:&quot; -v x:password \
231     &quot;$SETTINGS_FILE&quot;)
232
233 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
234 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
235 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
236
237 echo &quot;machine ${machine%:*} login $user password $pass&quot; &gt; ~/.netrc
238 </command>
239     </hudson.tasks.Shell>
240     <hudson.tasks.Shell>
241       <command>#!/bin/bash
242 # SPDX-License-Identifier: EPL-1.0
243 ##############################################################################
244 # Copyright (c) 2017 The Linux Foundation and others.
245 #
246 # All rights reserved. This program and the accompanying materials
247 # are made available under the terms of the Eclipse Public License v1.0
248 # which accompanies this distribution, and is available at
249 # http://www.eclipse.org/legal/epl-v10.html
250 ##############################################################################
251 echo &quot;---&gt; lftools-install.sh&quot;
252
253 # Script to install lftools via a version passed in via lf-infra-parameters
254 #
255 # Required parameters:
256 #
257 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
258 #                      set to a strict version number like '1.2.3' or using
259 #                      PEP-440 definitions.
260 #
261 #                      Examples:
262 #                          &lt;1.0.0
263 #                          &gt;=1.0.0,&lt;2.0.0
264 #
265 # By default a released version of lftools should always be used.
266 # The purpose of the 2 variables below is so that lftools devs can test
267 # unreleased versions of lftools. There are 2 methods to install a dev version
268 # of lftools:
269 #
270 #     1) gerrit patch: Used to test a patch that has not yet been merged.
271 #                      To do this set something like this:
272 #                          LFTOOLS_MODE=gerrit
273 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
274 #
275 #     2) git branch: Used to install an lftools version from a specific branch.
276 #                    To use this set the variables as follows:
277 #                          LFTOOLS_MODE=git
278 #                          LFTOOLS_REFSPEC=master
279 #
280 #     3) release : The intended use case and default setting.
281 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
282
283 LFTOOLS_MODE=release  # release | git | gerrit
284 LFTOOLS_REFSPEC=master
285
286 # Ensure we fail the job if any steps fail.
287 # DO NOT set -u as virtualenv's activate script has unbound variables
288 set -e -o pipefail
289
290 virtualenv --quiet &quot;/tmp/v/lftools&quot;
291 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
292 source &quot;/tmp/v/lftools/bin/activate&quot;
293 pip install --quiet --upgrade pip
294
295 case $LFTOOLS_MODE in
296     gerrit)
297         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
298         pushd /tmp/lftools
299         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
300         git checkout FETCH_HEAD
301         pip install --quiet --upgrade -r requirements.txt
302         pip install --quiet --upgrade -e .
303         popd
304         ;;
305
306     git)
307         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
308         ;;
309
310     release)
311         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
312             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
313         fi
314
315         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
316         ;;
317 esac
318
319 lftools --version
320
321 # pipdeptree prints out a lot of information because lftools pulls in many
322 # dependencies. Let's only print it if we want to debug.
323 # echo &quot;----&gt; Pip Dependency Tree&quot;
324 # pip install --quiet --upgrade pipdeptree
325 # pipdeptree
326
327 #!/bin/bash
328 # SPDX-License-Identifier: EPL-1.0
329 ##############################################################################
330 # Copyright (c) 2017 The Linux Foundation and others.
331 #
332 # All rights reserved. This program and the accompanying materials
333 # are made available under the terms of the Eclipse Public License v1.0
334 # which accompanies this distribution, and is available at
335 # http://www.eclipse.org/legal/epl-v10.html
336 ##############################################################################
337
338 # This file contains a list of variables that are generally useful in many
339 # scripts. It is meant to be sourced in other scripts so that the variables can
340 # be called.
341
342 MAVEN_OPTIONS=&quot;$(echo --show-version \
343     --batch-mode \
344     -Djenkins \
345     -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
346     -Dmaven.repo.local=/tmp/r \
347     -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r)&quot;
348 echo &quot;$MAVEN_OPTIONS&quot;
349
350 #!/bin/bash
351 # SPDX-License-Identifier: EPL-1.0
352 ##############################################################################
353 # Copyright (c) 2017 The Linux Foundation and others.
354 #
355 # All rights reserved. This program and the accompanying materials
356 # are made available under the terms of the Eclipse Public License v1.0
357 # which accompanies this distribution, and is available at
358 # http://www.eclipse.org/legal/epl-v10.html
359 ##############################################################################
360
361 # This script removes the -SNAPSHOT from a project to prepare it for release.
362
363 PATCH_DIR=&quot;$WORKSPACE/archives/patches&quot;
364 mkdir -p &quot;$PATCH_DIR&quot;
365
366 # Ensure we fail the job if any steps fail.
367 set -eu -o pipefail
368
369 echo &quot;$PROJECT&quot; &quot;$(git rev-parse --verify HEAD)&quot; | tee -a &quot;$PATCH_DIR/taglist.log&quot;
370
371 # Strip -SNAPSHOT from version to prepare release.
372 find . -name &quot;*.xml&quot; -print0 | xargs -0 sed -i 's/-SNAPSHOT//g'
373
374 git commit -am &quot;Release $PROJECT&quot;
375 git format-patch --stdout &quot;origin/$GERRIT_BRANCH&quot; &gt; &quot;$PATCH_DIR/${PROJECT//\//-}.patch&quot;
376 git bundle create &quot;$PATCH_DIR/${PROJECT//\//-}.bundle&quot; &quot;origin/${GERRIT_BRANCH}..HEAD&quot;
377
378 #!/bin/bash
379 # SPDX-License-Identifier: EPL-1.0
380 ##############################################################################
381 # Copyright (c) 2017 The Linux Foundation and others.
382 #
383 # All rights reserved. This program and the accompanying materials
384 # are made available under the terms of the Eclipse Public License v1.0
385 # which accompanies this distribution, and is available at
386 # http://www.eclipse.org/legal/epl-v10.html
387 ##############################################################################
388
389 # This script builds a Maven project and deploys it into a staging repo which
390 # can be used to deploy elsewhere later eg. Nexus staging / snapshot repos.
391
392 # DO NOT enable -u because $MAVEN_PARAMS and $MAVEN_OPTIONS could be unbound.
393 # Ensure we fail the job if any steps fail.
394 set -e -o pipefail
395 set +u
396
397 export MAVEN_OPTS
398
399 # Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
400 # shellcheck disable=SC2086
401 $MVN clean deploy \
402     --global-settings &quot;$GLOBAL_SETTINGS_FILE&quot; \
403     --settings &quot;$SETTINGS_FILE&quot; \
404     -DaltDeploymentRepository=staging::default::file:&quot;$WORKSPACE&quot;/m2repo \
405     $MAVEN_PARAMS $MAVEN_OPTIONS
406
407 #!/bin/bash
408 # SPDX-License-Identifier: EPL-1.0
409 ##############################################################################
410 # Copyright (c) 2017 The Linux Foundation and others.
411 #
412 # All rights reserved. This program and the accompanying materials
413 # are made available under the terms of the Eclipse Public License v1.0
414 # which accompanies this distribution, and is available at
415 # http://www.eclipse.org/legal/epl-v10.html
416 ##############################################################################
417
418 # This script publishes artifacts to a staging repo in Nexus.
419 #
420 # $WORKSPACE/m2repo   :  Exists and used to deploy the staging repository.
421 # $NEXUS_URL          :  Jenkins global variable should be defined.
422 # $STAGING_PROFILE_ID :  Provided by a job parameter.
423
424 # Ensure we fail the job if any steps fail.
425 set -eu -o pipefail
426
427 TMP_FILE=&quot;$(mktemp)&quot;
428 lftools deploy nexus-stage &quot;$NEXUS_URL&quot; &quot;$STAGING_PROFILE_ID&quot; &quot;$WORKSPACE/m2repo&quot; | tee &quot;$TMP_FILE&quot;
429 staging_repo=$(sed -n -e 's/Staging repository \(.*\) created\./\1/p' &quot;$TMP_FILE&quot;)
430
431 # Store repo info to a file in archives
432 mkdir -p &quot;$WORKSPACE/archives&quot;
433 echo &quot;$staging_repo&quot; &gt; &quot;$WORKSPACE/archives/staging-repo.txt&quot;
434
435 # Cleanup
436 rm &quot;$TMP_FILE&quot;
437 </command>
438     </hudson.tasks.Shell>
439     <hudson.tasks.Shell>
440       <command>#!/bin/bash
441 set +e  # DO NOT cause build failure if any of the rm calls fail.
442
443 rm &quot;$GLOBAL_SETTINGS_FILE&quot; &quot;$SETTINGS_FILE&quot;
444
445 # In some cases we use the lf-provide-maven-settings macro to produce
446 # a &quot;$HOME/.netrc&quot; file containing credentials. Remove that file here
447 # too if it exists.
448 rm &quot;$HOME/.netrc&quot;
449
450 # DO NOT fail build if any of the above lines fail.
451 exit 0
452 </command>
453     </hudson.tasks.Shell>
454   </builders>
455   <publishers>
456     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
457       <buildSteps>
458         <hudson.tasks.Shell>
459           <command>#!/bin/bash
460 # SPDX-License-Identifier: EPL-1.0
461 ##############################################################################
462 # Copyright (c) 2017 The Linux Foundation and others.
463 #
464 # All rights reserved. This program and the accompanying materials
465 # are made available under the terms of the Eclipse Public License v1.0
466 # which accompanies this distribution, and is available at
467 # http://www.eclipse.org/legal/epl-v10.html
468 ##############################################################################
469 echo &quot;---&gt; sysstat.sh&quot;
470 set +e  # DON'T fail build if script fails.
471
472 OS=$(facter operatingsystem)
473 case &quot;$OS&quot; in
474     Ubuntu)
475         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
476
477         # Dont run the script when systat is not enabled by default
478         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
479             exit 0
480         fi
481     ;;
482     CentOS|RedHat)
483         SYSSTAT_PATH=&quot;/var/log/sa&quot;
484     ;;
485     *)
486         # nothing to do
487         exit 0
488     ;;
489 esac
490
491 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
492 mkdir -p &quot;$SAR_DIR&quot;
493 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
494 # convert sar data to ascii format
495 while IFS=&quot;&quot; read -r s
496 do
497     [ -f &quot;$s&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$s&quot; &gt; &quot;$SAR_DIR/sar${s//[!0-9]/}&quot;
498 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
499
500 # DON'T fail build if script fails.
501 exit 0
502 </command>
503         </hudson.tasks.Shell>
504         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
505           <managedFiles>
506             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
507               <fileId>jenkins-log-archives-settings</fileId>
508               <targetLocation/>
509               <variable>SETTINGS_FILE</variable>
510             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
511           </managedFiles>
512         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
513         <EnvInjectBuilder>
514           <info>
515             <propertiesContent>SERVER_ID=logs</propertiesContent>
516           </info>
517         </EnvInjectBuilder>
518         <hudson.tasks.Shell>
519           <command>#!/bin/bash
520 # SPDX-License-Identifier: EPL-1.0
521 ##############################################################################
522 # Copyright (c) 2017 The Linux Foundation and others.
523 #
524 # All rights reserved. This program and the accompanying materials
525 # are made available under the terms of the Eclipse Public License v1.0
526 # which accompanies this distribution, and is available at
527 # http://www.eclipse.org/legal/epl-v10.html
528 ##############################################################################
529 echo &quot;---&gt; create-netrc.sh&quot;
530
531 # Ensure we fail the job if any steps fail.
532 set -eu -o pipefail
533
534 NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
535 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
536     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
537     -v x:username -o &quot;:&quot; -v x:password \
538     &quot;$SETTINGS_FILE&quot;)
539
540 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
541 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
542 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
543
544 echo &quot;machine ${machine%:*} login $user password $pass&quot; &gt; ~/.netrc
545 </command>
546         </hudson.tasks.Shell>
547         <hudson.tasks.Shell>
548           <command>#!/bin/bash
549 # SPDX-License-Identifier: EPL-1.0
550 ##############################################################################
551 # Copyright (c) 2017 The Linux Foundation and others.
552 #
553 # All rights reserved. This program and the accompanying materials
554 # are made available under the terms of the Eclipse Public License v1.0
555 # which accompanies this distribution, and is available at
556 # http://www.eclipse.org/legal/epl-v10.html
557 ##############################################################################
558 echo &quot;---&gt; lftools-install.sh&quot;
559
560 # Script to install lftools via a version passed in via lf-infra-parameters
561 #
562 # Required parameters:
563 #
564 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
565 #                      set to a strict version number like '1.2.3' or using
566 #                      PEP-440 definitions.
567 #
568 #                      Examples:
569 #                          &lt;1.0.0
570 #                          &gt;=1.0.0,&lt;2.0.0
571 #
572 # By default a released version of lftools should always be used.
573 # The purpose of the 2 variables below is so that lftools devs can test
574 # unreleased versions of lftools. There are 2 methods to install a dev version
575 # of lftools:
576 #
577 #     1) gerrit patch: Used to test a patch that has not yet been merged.
578 #                      To do this set something like this:
579 #                          LFTOOLS_MODE=gerrit
580 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
581 #
582 #     2) git branch: Used to install an lftools version from a specific branch.
583 #                    To use this set the variables as follows:
584 #                          LFTOOLS_MODE=git
585 #                          LFTOOLS_REFSPEC=master
586 #
587 #     3) release : The intended use case and default setting.
588 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
589
590 LFTOOLS_MODE=release  # release | git | gerrit
591 LFTOOLS_REFSPEC=master
592
593 # Ensure we fail the job if any steps fail.
594 # DO NOT set -u as virtualenv's activate script has unbound variables
595 set -e -o pipefail
596
597 virtualenv --quiet &quot;/tmp/v/lftools&quot;
598 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
599 source &quot;/tmp/v/lftools/bin/activate&quot;
600 pip install --quiet --upgrade pip
601
602 case $LFTOOLS_MODE in
603     gerrit)
604         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
605         pushd /tmp/lftools
606         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
607         git checkout FETCH_HEAD
608         pip install --quiet --upgrade -r requirements.txt
609         pip install --quiet --upgrade -e .
610         popd
611         ;;
612
613     git)
614         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
615         ;;
616
617     release)
618         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
619             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
620         fi
621
622         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
623         ;;
624 esac
625
626 lftools --version
627
628 # pipdeptree prints out a lot of information because lftools pulls in many
629 # dependencies. Let's only print it if we want to debug.
630 # echo &quot;----&gt; Pip Dependency Tree&quot;
631 # pip install --quiet --upgrade pipdeptree
632 # pipdeptree
633
634 #!/bin/bash
635 # SPDX-License-Identifier: EPL-1.0
636 ##############################################################################
637 # Copyright (c) 2017 The Linux Foundation and others.
638 #
639 # All rights reserved. This program and the accompanying materials
640 # are made available under the terms of the Eclipse Public License v1.0
641 # which accompanies this distribution, and is available at
642 # http://www.eclipse.org/legal/epl-v10.html
643 ##############################################################################
644 echo &quot;---&gt; logs-deploy.sh&quot;
645
646 # Ensure we fail the job if any steps fail.
647 set -eu -o pipefail
648
649 set -x  # Trace commands for this script to make debugging easier.
650
651 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
652 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
653
654 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
655 then
656     set +x # Disable trace since we no longer need it
657
658     echo &quot;WARNING: Logging server not set&quot;
659 else
660     NEXUS_URL=&quot;${NEXUSPROXY:-$NEXUS_URL}&quot;
661     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
662     BUILD_URL=&quot;${BUILD_URL}&quot;
663
664     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
665     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
666
667     set +x  # Disable trace since we no longer need it.
668
669     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
670 fi
671 </command>
672         </hudson.tasks.Shell>
673         <hudson.tasks.Shell>
674           <command>#!/bin/bash
675 # SPDX-License-Identifier: EPL-1.0
676 ##############################################################################
677 # Copyright (c) 2017 The Linux Foundation and others.
678 #
679 # All rights reserved. This program and the accompanying materials
680 # are made available under the terms of the Eclipse Public License v1.0
681 # which accompanies this distribution, and is available at
682 # http://www.eclipse.org/legal/epl-v10.html
683 ##############################################################################
684
685 # Clear log credential files
686 rm &quot;$SETTINGS_FILE&quot;
687 rm ~/.netrc
688 </command>
689         </hudson.tasks.Shell>
690         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
691           <regexp>^Build logs: .*</regexp>
692         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
693       </buildSteps>
694       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
695       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
696       <markBuildUnstable>false</markBuildUnstable>
697     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
698     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
699       <patterns>
700         <hudson.plugins.ws__cleanup.Pattern>
701           <pattern>**/*.jenkins-trigger</pattern>
702           <type>EXCLUDE</type>
703         </hudson.plugins.ws__cleanup.Pattern>
704       </patterns>
705       <deleteDirs>false</deleteDirs>
706       <cleanupMatrixParent>false</cleanupMatrixParent>
707       <externalDelete/>
708       <cleanWhenSuccess>true</cleanWhenSuccess>
709       <cleanWhenUnstable>true</cleanWhenUnstable>
710       <cleanWhenFailure>true</cleanWhenFailure>
711       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
712       <cleanWhenAborted>true</cleanWhenAborted>
713       <notFailBuild>true</notFailBuild>
714     </hudson.plugins.ws__cleanup.WsCleanup>
715   </publishers>
716   <buildWrappers>
717     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
718     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
719       <timeoutMinutes>30</timeoutMinutes>
720       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
721       <failBuild>true</failBuild>
722       <writingDescription>false</writingDescription>
723       <timeoutPercentage>0</timeoutPercentage>
724       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
725       <timeoutType>absolute</timeoutType>
726     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
727     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
728     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
729       <user>test-credential</user>
730     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
731     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
732     <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
733       <managedFiles>
734         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
735           <fileId>npmrc</fileId>
736           <targetLocation>$HOME/.npmrc</targetLocation>
737           <variable/>
738         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
739       </managedFiles>
740     </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
741   </buildWrappers>
742 </project>