Make lftools version configurable
[releng/global-jjb.git] / jjb-test / expected-xml / github-ciman-jjb-merge
1 <?xml version="1.0" encoding="utf-8"?>
2 <project>
3   <actions/>
4   <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
5   <keepDependencies>false</keepDependencies>
6   <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
7   <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
8   <concurrentBuild>false</concurrentBuild>
9   <assignedNode>build-vm</assignedNode>
10   <canRoam>false</canRoam>
11   <properties>
12     <com.coravy.hudson.plugins.github.GithubProjectProperty>
13       <projectUrl>https://github.com/example-org/releng/ciman</projectUrl>
14     </com.coravy.hudson.plugins.github.GithubProjectProperty>
15     <hudson.model.ParametersDefinitionProperty>
16       <parameterDefinitions>
17         <hudson.model.StringParameterDefinition>
18           <name>PROJECT</name>
19           <description>Parameter to identify a Gerrit project. This is typically the
20 project repo path as exists in Gerrit.
21 For example: ofextensions/circuitsw
22 </description>
23           <defaultValue>releng/ciman</defaultValue>
24         </hudson.model.StringParameterDefinition>
25         <hudson.model.StringParameterDefinition>
26           <name>STREAM</name>
27           <description>Stream is often set to the same name as 'branch' but can
28 sometimes be used as a name representing a project's release code
29 name.
30 </description>
31           <defaultValue>master</defaultValue>
32         </hudson.model.StringParameterDefinition>
33         <hudson.model.StringParameterDefinition>
34           <name>GERRIT_PROJECT</name>
35           <description>Parameter to identify Gerrit project. This is typically the
36 project repo path as exists in Gerrit.
37 For example: ofextensions/circuitsw
38
39 Note that Gerrit will override this parameter automatically if a
40 job is triggered by Gerrit.
41 </description>
42           <defaultValue>releng/ciman</defaultValue>
43         </hudson.model.StringParameterDefinition>
44         <hudson.model.StringParameterDefinition>
45           <name>GERRIT_BRANCH</name>
46           <description>Parameter to identify a Gerrit branch.
47
48 Note that Gerrit will override this parameter automatically if a
49 job is triggered by Gerrit.
50 </description>
51           <defaultValue>master</defaultValue>
52         </hudson.model.StringParameterDefinition>
53         <hudson.model.StringParameterDefinition>
54           <name>GERRIT_REFSPEC</name>
55           <description>Parameter to identify a refspec when pulling from Gerrit.
56
57 Note that Gerrit will override this parameter automatically if a
58 job is triggered by Gerrit.
59 </description>
60           <defaultValue/>
61         </hudson.model.StringParameterDefinition>
62         <hudson.model.StringParameterDefinition>
63           <name>LFTOOLS_VERSION</name>
64           <description>Version of lftools to install. Can be a specific version like
65 '0.6.0' or a PEP-440 definition.
66 https://www.python.org/dev/peps/pep-0440/
67 For example '&lt;1.0.0' or '&gt;=1.0.0,&lt;2.0.0'.
68 </description>
69           <defaultValue>&lt;1.0.0</defaultValue>
70         </hudson.model.StringParameterDefinition>
71         <hudson.model.StringParameterDefinition>
72           <name>JJB_VERSION</name>
73           <description>Jenkins Job Builder version to download and install.</description>
74           <defaultValue>1.6.2</defaultValue>
75         </hudson.model.StringParameterDefinition>
76       </parameterDefinitions>
77     </hudson.model.ParametersDefinitionProperty>
78   </properties>
79   <scm class="hudson.plugins.git.GitSCM">
80     <configVersion>2</configVersion>
81     <userRemoteConfigs>
82       <hudson.plugins.git.UserRemoteConfig>
83         <name>origin</name>
84         <refspec/>
85         <url>git@github.com:example-org/releng/ciman</url>
86         <credentialsId>test-credential</credentialsId>
87       </hudson.plugins.git.UserRemoteConfig>
88     </userRemoteConfigs>
89     <branches>
90       <hudson.plugins.git.BranchSpec>
91         <name>**</name>
92       </hudson.plugins.git.BranchSpec>
93     </branches>
94     <excludedUsers/>
95     <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
96     <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
97     <authorOrCommitter>false</authorOrCommitter>
98     <wipeOutWorkspace>true</wipeOutWorkspace>
99     <pruneBranches>false</pruneBranches>
100     <remotePoll>false</remotePoll>
101     <gitTool>Default</gitTool>
102     <submoduleCfg class="list"/>
103     <relativeTargetDir/>
104     <reference/>
105     <gitConfigName/>
106     <gitConfigEmail/>
107     <skipTag>true</skipTag>
108     <scmName/>
109     <useShallowClone>false</useShallowClone>
110     <ignoreNotifyCommit>false</ignoreNotifyCommit>
111     <extensions>
112       <hudson.plugins.git.extensions.impl.SubmoduleOption>
113         <disableSubmodules>false</disableSubmodules>
114         <recursiveSubmodules>true</recursiveSubmodules>
115         <trackingSubmodules>false</trackingSubmodules>
116         <reference/>
117         <timeout>10</timeout>
118       </hudson.plugins.git.extensions.impl.SubmoduleOption>
119       <hudson.plugins.git.extensions.impl.WipeWorkspace/>
120     </extensions>
121   </scm>
122   <triggers class="vector">
123     <com.cloudbees.jenkins.GitHubPushTrigger>
124       <spec/>
125     </com.cloudbees.jenkins.GitHubPushTrigger>
126     <hudson.triggers.SCMTrigger>
127       <spec/>
128       <ignorePostCommitHooks>false</ignorePostCommitHooks>
129     </hudson.triggers.SCMTrigger>
130     <org.jenkinsci.plugins.ghprb.GhprbTrigger>
131       <spec/>
132       <adminlist>tykeal</adminlist>
133       <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
134       <whitelist>jpwku
135 tykeal
136 zxiiro</whitelist>
137       <orgslist>example-org</orgslist>
138       <cron/>
139       <triggerPhrase>^remerge$</triggerPhrase>
140       <onlyTriggerPhrase>true</onlyTriggerPhrase>
141       <useGitHubHooks>true</useGitHubHooks>
142       <permitAll>false</permitAll>
143       <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
144       <extensions>
145         <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
146           <commitStatusContext>JJB Merge</commitStatusContext>
147         </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
148       </extensions>
149     </org.jenkinsci.plugins.ghprb.GhprbTrigger>
150   </triggers>
151   <builders>
152     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
153       <managedFiles>
154         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
155           <fileId>jjbini</fileId>
156           <targetLocation>$HOME/.config/jenkins_jobs/jenkins_jobs.ini</targetLocation>
157           <variable/>
158         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
159       </managedFiles>
160     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
161     <hudson.tasks.Shell>
162       <command>#!/bin/bash
163 # SPDX-License-Identifier: EPL-1.0
164 ##############################################################################
165 # Copyright (c) 2017 The Linux Foundation and others.
166 #
167 # All rights reserved. This program and the accompanying materials
168 # are made available under the terms of the Eclipse Public License v1.0
169 # which accompanies this distribution, and is available at
170 # http://www.eclipse.org/legal/epl-v10.html
171 ##############################################################################
172 echo &quot;---&gt; jjb-install.sh&quot;
173
174 # Ensure we fail the job if any steps fail.
175 # DO NOT set -u as virtualenv's activate script has unbound variables
176 set -e -o pipefail
177
178 virtualenv &quot;/tmp/v/jjb&quot;
179 # shellcheck source=/tmp/v/jjb/bin/activate disable=SC1091
180 source &quot;/tmp/v/jjb/bin/activate&quot;
181 pip install --quiet --upgrade pip
182 pip install --quiet --upgrade pipdeptree
183 pip install --quiet --upgrade &quot;jenkins-job-builder==$JJB_VERSION&quot;
184
185 echo &quot;----&gt; Pip Dependency Tree&quot;
186 pipdeptree
187
188 #!/bin/bash
189 # SPDX-License-Identifier: EPL-1.0
190 ##############################################################################
191 # Copyright (c) 2017 The Linux Foundation and others.
192 #
193 # All rights reserved. This program and the accompanying materials
194 # are made available under the terms of the Eclipse Public License v1.0
195 # which accompanies this distribution, and is available at
196 # http://www.eclipse.org/legal/epl-v10.html
197 ##############################################################################
198 echo &quot;---&gt; jjb-merge-job.sh&quot;
199
200 # Ensure we fail the job if any steps fail.
201 set -eu -o pipefail
202
203 jenkins-jobs update --recursive --delete-old --workers 4 --exclude jjb-test jjb
204 </command>
205     </hudson.tasks.Shell>
206   </builders>
207   <publishers>
208     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
209       <buildSteps>
210         <hudson.tasks.Shell>
211           <command>#!/bin/bash
212 # SPDX-License-Identifier: EPL-1.0
213 ##############################################################################
214 # Copyright (c) 2017 The Linux Foundation and others.
215 #
216 # All rights reserved. This program and the accompanying materials
217 # are made available under the terms of the Eclipse Public License v1.0
218 # which accompanies this distribution, and is available at
219 # http://www.eclipse.org/legal/epl-v10.html
220 ##############################################################################
221 echo &quot;---&gt; sysstat.sh&quot;
222 set +e  # DON'T fail build if script fails.
223
224 OS=$(facter operatingsystem)
225 case &quot;$OS&quot; in
226     Ubuntu)
227         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
228
229         # Dont run the script when systat is not enabled by default
230         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
231             exit 0
232         fi
233     ;;
234     CentOS|RedHat)
235         SYSSTAT_PATH=&quot;/var/log/sa&quot;
236     ;;
237     *)
238         # nothing to do
239         exit 0
240     ;;
241 esac
242
243 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
244 mkdir -p &quot;$SAR_DIR&quot;
245 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
246 # convert sar data to ascii format
247 while IFS=&quot;&quot; read -r s
248 do
249     [ -f &quot;$s&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$s&quot; &gt; &quot;$SAR_DIR/sar${s//[!0-9]/}&quot;
250 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
251
252 # DON'T fail build if script fails.
253 exit 0
254 </command>
255         </hudson.tasks.Shell>
256         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
257           <managedFiles>
258             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
259               <fileId>jenkins-log-archives-settings</fileId>
260               <targetLocation/>
261               <variable>SETTINGS_FILE</variable>
262             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
263           </managedFiles>
264         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
265         <EnvInjectBuilder>
266           <info>
267             <propertiesContent>SERVER_ID=logs</propertiesContent>
268           </info>
269         </EnvInjectBuilder>
270         <hudson.tasks.Shell>
271           <command>#!/bin/bash
272 # SPDX-License-Identifier: EPL-1.0
273 ##############################################################################
274 # Copyright (c) 2017 The Linux Foundation and others.
275 #
276 # All rights reserved. This program and the accompanying materials
277 # are made available under the terms of the Eclipse Public License v1.0
278 # which accompanies this distribution, and is available at
279 # http://www.eclipse.org/legal/epl-v10.html
280 ##############################################################################
281 echo &quot;---&gt; create-netrc.sh&quot;
282
283 # Ensure we fail the job if any steps fail.
284 set -eu -o pipefail
285
286 NEXUS_URL=&quot;${NEXUS_URL:-$NEXUSPROXY}&quot;
287 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
288     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
289     -v x:username -o &quot;:&quot; -v x:password \
290     &quot;$SETTINGS_FILE&quot;)
291
292 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
293 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
294 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
295
296 echo &quot;machine $machine login $user password $pass&quot; &gt; ~/.netrc
297 </command>
298         </hudson.tasks.Shell>
299         <hudson.tasks.Shell>
300           <command>#!/bin/bash
301 # SPDX-License-Identifier: EPL-1.0
302 ##############################################################################
303 # Copyright (c) 2017 The Linux Foundation and others.
304 #
305 # All rights reserved. This program and the accompanying materials
306 # are made available under the terms of the Eclipse Public License v1.0
307 # which accompanies this distribution, and is available at
308 # http://www.eclipse.org/legal/epl-v10.html
309 ##############################################################################
310 echo &quot;---&gt; lftools-install.sh&quot;
311
312 # Script to install lftools via a version passed in via lf-infra-parameters
313 #
314 # Required parameters:
315 #
316 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
317 #                      set to a strict version number like '1.2.3' or using
318 #                      PEP-440 definitions.
319 #
320 #                      Examples:
321 #                          &lt;1.0.0
322 #                          &gt;=1.0.0,&lt;2.0.0
323 #
324 # By default a released version of lftools should always be used.
325 # The purpose of the 2 variables below is so that lftools devs can test
326 # unreleased versions of lftools. There are 2 methods to install a dev version
327 # of lftools:
328 #
329 #     1) gerrit patch: Used to test a patch that has not yet been merged.
330 #                      To do this set something like this:
331 #                          LFTOOLS_MODE=gerrit
332 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
333 #
334 #     2) git branch: Used to install an lftools version from a specific branch.
335 #                    To use this set the variables as follows:
336 #                          LFTOOLS_MODE=git
337 #                          LFTOOLS_REFSPEC=master
338 #
339 #     3) release : The intended use case and default setting.
340 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
341
342 LFTOOLS_MODE=release  # release | git | gerrit
343 LFTOOLS_REFSPEC=master
344
345 # Ensure we fail the job if any steps fail.
346 # DO NOT set -u as virtualenv's activate script has unbound variables
347 set -e -o pipefail
348
349 virtualenv --quiet &quot;/tmp/v/lftools&quot;
350 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
351 source &quot;/tmp/v/lftools/bin/activate&quot;
352 pip install --quiet --upgrade pip
353
354 case $LFTOOLS_MODE in
355     gerrit)
356         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
357         pushd /tmp/lftools
358         git fetch origin &quot;$LFTOOLS_REFSPEC&quot;
359         git checkout FETCH_HEAD
360         pip install --quiet --upgrade -r requirements.txt
361         pip install --quiet --upgrade -e .
362         popd
363         ;;
364
365     git)
366         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@&quot;$BRANCH&quot;
367         ;;
368
369     release)
370         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
371             LFTOOLS_VERSION=&quot;==$LFTOOLS_VERSION&quot;
372         fi
373
374         pip install --quiet --upgrade &quot;lftools${LFTOOLS_VERSION}&quot;
375         ;;
376 esac
377
378 lftools --version
379
380 # pipdeptree prints out a lot of information because lftools pulls in many
381 # dependencies. Let's only print it if we want to debug.
382 # echo &quot;----&gt; Pip Dependency Tree&quot;
383 # pip install --quiet --upgrade pipdeptree
384 # pipdeptree
385
386 #!/bin/bash
387 # SPDX-License-Identifier: EPL-1.0
388 ##############################################################################
389 # Copyright (c) 2017 The Linux Foundation and others.
390 #
391 # All rights reserved. This program and the accompanying materials
392 # are made available under the terms of the Eclipse Public License v1.0
393 # which accompanies this distribution, and is available at
394 # http://www.eclipse.org/legal/epl-v10.html
395 ##############################################################################
396 echo &quot;---&gt; logs-deploy.sh&quot;
397
398 # Ensure we fail the job if any steps fail.
399 set -eu -o pipefail
400
401 set -x  # Trace commands for this script to make debugging easier.
402
403 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
404 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
405
406 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
407 then
408     set +x # Disable trace since we no longer need it
409
410     echo &quot;WARNING: Logging server not set&quot;
411 else
412     NEXUS_URL=&quot;${NEXUS_URL:-$NEXUSPROXY}&quot;
413     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
414     BUILD_URL=&quot;${BUILD_URL}&quot;
415
416     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
417     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
418
419     set +x  # Disable trace since we no longer need it.
420
421     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
422 fi
423 </command>
424         </hudson.tasks.Shell>
425         <hudson.tasks.Shell>
426           <command>#!/bin/bash
427 # SPDX-License-Identifier: EPL-1.0
428 ##############################################################################
429 # Copyright (c) 2017 The Linux Foundation and others.
430 #
431 # All rights reserved. This program and the accompanying materials
432 # are made available under the terms of the Eclipse Public License v1.0
433 # which accompanies this distribution, and is available at
434 # http://www.eclipse.org/legal/epl-v10.html
435 ##############################################################################
436
437 # Clear log credential files
438 rm &quot;$SETTINGS_FILE&quot;
439 rm ~/.netrc
440 </command>
441         </hudson.tasks.Shell>
442         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
443           <regexp>^Build logs: .*</regexp>
444         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
445       </buildSteps>
446       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
447       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
448       <markBuildUnstable>false</markBuildUnstable>
449     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
450     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
451       <patterns>
452         <hudson.plugins.ws__cleanup.Pattern>
453           <pattern>**/*.jenkins-trigger</pattern>
454           <type>EXCLUDE</type>
455         </hudson.plugins.ws__cleanup.Pattern>
456       </patterns>
457       <deleteDirs>false</deleteDirs>
458       <cleanupMatrixParent>false</cleanupMatrixParent>
459       <externalDelete/>
460       <cleanWhenSuccess>true</cleanWhenSuccess>
461       <cleanWhenUnstable>true</cleanWhenUnstable>
462       <cleanWhenFailure>true</cleanWhenFailure>
463       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
464       <cleanWhenAborted>true</cleanWhenAborted>
465       <notFailBuild>true</notFailBuild>
466     </hudson.plugins.ws__cleanup.WsCleanup>
467   </publishers>
468   <buildWrappers>
469     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
470     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
471       <timeoutMinutes>10</timeoutMinutes>
472       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
473       <failBuild>true</failBuild>
474       <writingDescription>false</writingDescription>
475       <timeoutPercentage>0</timeoutPercentage>
476       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
477       <timeoutType>absolute</timeoutType>
478     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
479     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
480     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
481       <user>test-credential</user>
482     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
483     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
484   </buildWrappers>
485 </project>