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