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