Add default refspec reference
[releng/global-jjb.git] / jjb-test / expected-xml / github-ciman-packer-verify
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>true</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>refs/heads/master</defaultValue>
61         </hudson.model.StringParameterDefinition>
62         <hudson.model.StringParameterDefinition>
63           <name>PACKER_VERSION</name>
64           <description>Packer version to download and install.</description>
65           <defaultValue>1.0.2</defaultValue>
66         </hudson.model.StringParameterDefinition>
67       </parameterDefinitions>
68     </hudson.model.ParametersDefinitionProperty>
69   </properties>
70   <scm class="hudson.plugins.git.GitSCM">
71     <configVersion>2</configVersion>
72     <userRemoteConfigs>
73       <hudson.plugins.git.UserRemoteConfig>
74         <name>origin</name>
75         <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
76         <url>git@github.com:example-org/releng/ciman</url>
77         <credentialsId>test-credential</credentialsId>
78       </hudson.plugins.git.UserRemoteConfig>
79     </userRemoteConfigs>
80     <branches>
81       <hudson.plugins.git.BranchSpec>
82         <name>**</name>
83       </hudson.plugins.git.BranchSpec>
84     </branches>
85     <excludedUsers/>
86     <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
87     <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
88     <authorOrCommitter>false</authorOrCommitter>
89     <wipeOutWorkspace>true</wipeOutWorkspace>
90     <pruneBranches>false</pruneBranches>
91     <remotePoll>false</remotePoll>
92     <gitTool>Default</gitTool>
93     <submoduleCfg class="list"/>
94     <relativeTargetDir/>
95     <reference/>
96     <gitConfigName/>
97     <gitConfigEmail/>
98     <skipTag>true</skipTag>
99     <scmName/>
100     <useShallowClone>false</useShallowClone>
101     <ignoreNotifyCommit>false</ignoreNotifyCommit>
102     <extensions>
103       <hudson.plugins.git.extensions.impl.SubmoduleOption>
104         <disableSubmodules>false</disableSubmodules>
105         <recursiveSubmodules>true</recursiveSubmodules>
106         <trackingSubmodules>false</trackingSubmodules>
107         <reference/>
108         <timeout>10</timeout>
109       </hudson.plugins.git.extensions.impl.SubmoduleOption>
110       <hudson.plugins.git.extensions.impl.WipeWorkspace/>
111     </extensions>
112   </scm>
113   <triggers class="vector">
114     <org.jenkinsci.plugins.ghprb.GhprbTrigger>
115       <spec/>
116       <adminlist/>
117       <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
118       <whitelist/>
119       <orgslist/>
120       <cron/>
121       <triggerPhrase>^recheck$</triggerPhrase>
122       <onlyTriggerPhrase>false</onlyTriggerPhrase>
123       <useGitHubHooks>true</useGitHubHooks>
124       <permitAll>true</permitAll>
125       <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
126       <extensions>
127         <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
128           <commitStatusContext>Packer Verify</commitStatusContext>
129         </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
130       </extensions>
131     </org.jenkinsci.plugins.ghprb.GhprbTrigger>
132   </triggers>
133   <builders>
134     <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
135       <managedFiles>
136         <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
137           <fileId>ci-packer-cloud-env</fileId>
138           <targetLocation/>
139           <variable>CLOUDENV</variable>
140         </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
141       </managedFiles>
142     </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
143     <EnvInjectBuilder>
144       <info>
145         <propertiesContent>PACKER_VERSION=1.0.2
146 </propertiesContent>
147       </info>
148     </EnvInjectBuilder>
149     <hudson.tasks.Shell>
150       <command>#!/bin/bash
151 # SPDX-License-Identifier: EPL-1.0
152 ##############################################################################
153 # Copyright (c) 2017 The Linux Foundation and others.
154 #
155 # All rights reserved. This program and the accompanying materials
156 # are made available under the terms of the Eclipse Public License v1.0
157 # which accompanies this distribution, and is available at
158 # http://www.eclipse.org/legal/epl-v10.html
159 ##############################################################################
160 echo &quot;---&gt; packer-install.sh&quot;
161 # The script checks for the packer binaries and installs the binary
162 # if its not available
163
164 # $PACKER_VERSION        : Define a packer version passed as job paramter
165
166 PACKER_VERSION=&quot;${PACKER_VERSION:-1.0.2}&quot;
167
168 # Ensure we fail the job if any steps fail.
169 set -eu -o pipefail
170 # Default packer binary made available on the build image
171 packer_bin=&quot;/usr/local/bin/packer.io&quot;
172
173 if hash &quot;$packer_bin&quot; 2&gt;/dev/null; then
174     echo &quot;packer.io command is available.&quot;
175 else
176     echo &quot;packer.io command not is available. Installing packer ...&quot;
177     # Installs Hashicorp's Packer binary, required for verify &amp; merge packer jobs
178     pushd packer
179     wget &quot;https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip&quot;
180     mkdir -p &quot;${WORKSPACE}/bin&quot;
181     unzip &quot;packer_${PACKER_VERSION}_linux_amd64.zip&quot; -d ${WORKSPACE}/bin/
182     # rename packer to avoid conflict with binary in cracklib
183     mv ${WORKSPACE}/bin/packer &quot;${WORKSPACE}/bin/packer.io&quot;
184     popd
185 fi
186
187 #!/bin/bash
188 # SPDX-License-Identifier: EPL-1.0
189 ##############################################################################
190 # Copyright (c) 2017 The Linux Foundation and others.
191 #
192 # All rights reserved. This program and the accompanying materials
193 # are made available under the terms of the Eclipse Public License v1.0
194 # which accompanies this distribution, and is available at
195 # http://www.eclipse.org/legal/epl-v10.html
196 ##############################################################################
197 echo &quot;---&gt; packer-validate.sh&quot;
198 # The script validates an packers files.
199
200 # $CLOUDENV            :  Provides the cloud credential file.
201
202 # Ensure we fail the job if any steps fail.
203 set -eu -o pipefail
204
205 PACKER_LOGS_DIR=&quot;$WORKSPACE/archives/packer&quot;
206 mkdir -p &quot;$PACKER_LOGS_DIR&quot;
207 export PATH=&quot;${WORKSPACE}/bin:$PATH&quot;
208
209 cd packer
210 varfiles=(../packer/vars/*.json)
211 templates=(../packer/templates/*.json)
212
213 for varfile in &quot;${varfiles[@]}&quot;; do
214     for template in &quot;${templates[@]}&quot;; do
215         export PACKER_LOG=&quot;yes&quot; &amp;&amp; \
216         export PACKER_LOG_PATH=&quot;$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log&quot; &amp;&amp; \
217                     packer.io validate -var-file=&quot;$CLOUDENV&quot; \
218                     -var-file=&quot;$varfile&quot; &quot;$template&quot;
219         if [ $? -ne 0 ]; then
220             break
221         fi
222     done
223 done
224 </command>
225     </hudson.tasks.Shell>
226     <hudson.tasks.Shell>
227       <command>#!/bin/bash
228 # SPDX-License-Identifier: EPL-1.0
229 ##############################################################################
230 # Copyright (c) 2017 The Linux Foundation and others.
231 #
232 # All rights reserved. This program and the accompanying materials
233 # are made available under the terms of the Eclipse Public License v1.0
234 # which accompanies this distribution, and is available at
235 # http://www.eclipse.org/legal/epl-v10.html
236 ##############################################################################
237 echo &quot;---&gt; packer-clear-credentials.sh&quot;
238
239 set +e  # DO NOT cause build failure if any of the rm calls fail.
240 rm &quot;$CLOUDENV&quot;
241 exit 0
242 </command>
243     </hudson.tasks.Shell>
244   </builders>
245   <publishers>
246     <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
247       <buildSteps>
248         <hudson.tasks.Shell>
249           <command>#!/bin/bash
250 # SPDX-License-Identifier: EPL-1.0
251 ##############################################################################
252 # Copyright (c) 2017 The Linux Foundation and others.
253 #
254 # All rights reserved. This program and the accompanying materials
255 # are made available under the terms of the Eclipse Public License v1.0
256 # which accompanies this distribution, and is available at
257 # http://www.eclipse.org/legal/epl-v10.html
258 ##############################################################################
259 echo &quot;---&gt; sysstat.sh&quot;
260 set +e  # DON'T fail build if script fails.
261
262 OS=$(facter operatingsystem)
263 case &quot;$OS&quot; in
264     Ubuntu)
265         SYSSTAT_PATH=&quot;/var/log/sysstat&quot;
266
267         # Dont run the script when systat is not enabled by default
268         if ! grep --quiet 'ENABLED=&quot;true&quot;' &quot;/etc/default/sysstat&quot;; then
269             exit 0
270         fi
271     ;;
272     CentOS|RedHat)
273         SYSSTAT_PATH=&quot;/var/log/sa&quot;
274     ;;
275     *)
276         # nothing to do
277         exit 0
278     ;;
279 esac
280
281 SAR_DIR=&quot;$WORKSPACE/archives/sar-reports&quot;
282 mkdir -p &quot;$SAR_DIR&quot;
283 cp &quot;$SYSSTAT_PATH/&quot;* &quot;$_&quot;
284 # convert sar data to ascii format
285 while IFS=&quot;&quot; read -r s
286 do
287     [ -f &quot;$s&quot; ] &amp;&amp; LC_TIME=POSIX sar -A -f &quot;$s&quot; &gt; &quot;$SAR_DIR/sar${s//[!0-9]/}&quot;
288 done &lt; &lt;(find &quot;$SYSSTAT_PATH&quot; -name &quot;sa[0-9]*&quot; || true)
289
290 # DON'T fail build if script fails.
291 exit 0
292 </command>
293         </hudson.tasks.Shell>
294         <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
295           <managedFiles>
296             <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
297               <fileId>jenkins-log-archives-settings</fileId>
298               <targetLocation/>
299               <variable>SETTINGS_FILE</variable>
300             </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
301           </managedFiles>
302         </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
303         <EnvInjectBuilder>
304           <info>
305             <propertiesContent>SERVER_ID=logs</propertiesContent>
306           </info>
307         </EnvInjectBuilder>
308         <hudson.tasks.Shell>
309           <command>#!/bin/bash
310 # SPDX-License-Identifier: EPL-1.0
311 ##############################################################################
312 # Copyright (c) 2017 The Linux Foundation and others.
313 #
314 # All rights reserved. This program and the accompanying materials
315 # are made available under the terms of the Eclipse Public License v1.0
316 # which accompanies this distribution, and is available at
317 # http://www.eclipse.org/legal/epl-v10.html
318 ##############################################################################
319 echo &quot;---&gt; create-netrc.sh&quot;
320
321 # Ensure we fail the job if any steps fail.
322 set -eu -o pipefail
323
324 NEXUS_URL=&quot;${NEXUS_URL:-$NEXUSPROXY}&quot;
325 CREDENTIAL=$(xmlstarlet sel -N &quot;x=http://maven.apache.org/SETTINGS/1.0.0&quot; \
326     -t -m &quot;/x:settings/x:servers/x:server[x:id='${SERVER_ID}']&quot; \
327     -v x:username -o &quot;:&quot; -v x:password \
328     &quot;$SETTINGS_FILE&quot;)
329
330 machine=$(echo &quot;$NEXUS_URL&quot; | awk -F/ '{print $3}')
331 user=$(echo &quot;$CREDENTIAL&quot; | cut -f1 -d:)
332 pass=$(echo &quot;$CREDENTIAL&quot; | cut -f2 -d:)
333
334 echo &quot;machine $machine login $user password $pass&quot; &gt; ~/.netrc
335 </command>
336         </hudson.tasks.Shell>
337         <hudson.tasks.Shell>
338           <command>#!/bin/bash
339 # SPDX-License-Identifier: EPL-1.0
340 ##############################################################################
341 # Copyright (c) 2017 The Linux Foundation and others.
342 #
343 # All rights reserved. This program and the accompanying materials
344 # are made available under the terms of the Eclipse Public License v1.0
345 # which accompanies this distribution, and is available at
346 # http://www.eclipse.org/legal/epl-v10.html
347 ##############################################################################
348 echo &quot;---&gt; lftools-install.sh&quot;
349
350 # Ensure we fail the job if any steps fail.
351 # DO NOT set -u as virtualenv's activate script has unbound variables
352 set -e -o pipefail
353
354 virtualenv --quiet &quot;/tmp/v/lftools&quot;
355 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
356 source &quot;/tmp/v/lftools/bin/activate&quot;
357 pip install --quiet --upgrade pip
358 pip install --quiet --upgrade &quot;lftools&lt;1.0.0&quot;
359
360 # pipdeptree prints out a lot of information because lftools pulls in many
361 # dependencies. Let's only print it if we want to debug.
362 # echo &quot;----&gt; Pip Dependency Tree&quot;
363 # pip install --quiet --upgrade pipdeptree
364 # pipdeptree
365
366 #!/bin/bash
367 # SPDX-License-Identifier: EPL-1.0
368 ##############################################################################
369 # Copyright (c) 2017 The Linux Foundation and others.
370 #
371 # All rights reserved. This program and the accompanying materials
372 # are made available under the terms of the Eclipse Public License v1.0
373 # which accompanies this distribution, and is available at
374 # http://www.eclipse.org/legal/epl-v10.html
375 ##############################################################################
376 echo &quot;---&gt; logs-deploy.sh&quot;
377
378 # Ensure we fail the job if any steps fail.
379 set -eu -o pipefail
380
381 set -x  # Trace commands for this script to make debugging easier.
382
383 ARCHIVE_ARTIFACTS=&quot;${ARCHIVE_ARTIFACTS:-}&quot;
384 LOGS_SERVER=&quot;${LOGS_SERVER:-None}&quot;
385
386 if [ &quot;${LOGS_SERVER}&quot; == 'None' ]
387 then
388     set +x # Disable trace since we no longer need it
389
390     echo &quot;WARNING: Logging server not set&quot;
391 else
392     NEXUS_URL=&quot;${NEXUS_URL:-$NEXUSPROXY}&quot;
393     NEXUS_PATH=&quot;${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}&quot;
394     BUILD_URL=&quot;${BUILD_URL}&quot;
395
396     lftools deploy archives -p &quot;$ARCHIVE_ARTIFACTS&quot; &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$WORKSPACE&quot;
397     lftools deploy logs &quot;$NEXUS_URL&quot; &quot;$NEXUS_PATH&quot; &quot;$BUILD_URL&quot;
398
399     set +x  # Disable trace since we no longer need it.
400
401     echo &quot;Build logs: &lt;a href=\&quot;$LOGS_SERVER/$NEXUS_PATH\&quot;&gt;$LOGS_SERVER/$NEXUS_PATH&lt;/a&gt;&quot;
402 fi
403 </command>
404         </hudson.tasks.Shell>
405         <hudson.tasks.Shell>
406           <command>#!/bin/bash
407 # SPDX-License-Identifier: EPL-1.0
408 ##############################################################################
409 # Copyright (c) 2017 The Linux Foundation and others.
410 #
411 # All rights reserved. This program and the accompanying materials
412 # are made available under the terms of the Eclipse Public License v1.0
413 # which accompanies this distribution, and is available at
414 # http://www.eclipse.org/legal/epl-v10.html
415 ##############################################################################
416
417 # Clear log credential files
418 rm &quot;$SETTINGS_FILE&quot;
419 rm ~/.netrc
420 </command>
421         </hudson.tasks.Shell>
422         <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
423           <regexp>^Build logs: .*</regexp>
424         </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
425       </buildSteps>
426       <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
427       <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
428       <markBuildUnstable>false</markBuildUnstable>
429     </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
430     <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
431       <patterns>
432         <hudson.plugins.ws__cleanup.Pattern>
433           <pattern>**/*.jenkins-trigger</pattern>
434           <type>EXCLUDE</type>
435         </hudson.plugins.ws__cleanup.Pattern>
436       </patterns>
437       <deleteDirs>false</deleteDirs>
438       <cleanupMatrixParent>false</cleanupMatrixParent>
439       <externalDelete/>
440       <cleanWhenSuccess>true</cleanWhenSuccess>
441       <cleanWhenUnstable>true</cleanWhenUnstable>
442       <cleanWhenFailure>true</cleanWhenFailure>
443       <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
444       <cleanWhenAborted>true</cleanWhenAborted>
445       <notFailBuild>true</notFailBuild>
446     </hudson.plugins.ws__cleanup.WsCleanup>
447   </publishers>
448   <buildWrappers>
449     <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
450     <hudson.plugins.build__timeout.BuildTimeoutWrapper>
451       <timeoutMinutes>10</timeoutMinutes>
452       <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
453       <failBuild>true</failBuild>
454       <writingDescription>false</writingDescription>
455       <timeoutPercentage>0</timeoutPercentage>
456       <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
457       <timeoutType>absolute</timeoutType>
458     </hudson.plugins.build__timeout.BuildTimeoutWrapper>
459     <hudson.plugins.timestamper.TimestamperBuildWrapper/>
460     <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
461       <user>test-credential</user>
462     </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
463     <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
464   </buildWrappers>
465 </project>