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