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