1 <?xml version="1.0" encoding="utf-8"?>
4 <description><!-- Managed by Jenkins Job Builder --></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>
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>
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
23 <defaultValue>releng/ciman</defaultValue>
24 </hudson.model.StringParameterDefinition>
25 <hudson.model.StringParameterDefinition>
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
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
39 Note that Gerrit will override this parameter automatically if a
40 job is triggered by Gerrit.
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.
48 Note that Gerrit will override this parameter automatically if a
49 job is triggered by Gerrit.
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.
57 Note that Gerrit will override this parameter automatically if a
58 job is triggered by Gerrit.
60 <defaultValue>refs/heads/master</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 '<1.0.0' or '>=1.0.0,<2.0.0'.
69 <defaultValue><1.0.0</defaultValue>
70 </hudson.model.StringParameterDefinition>
71 <hudson.model.StringParameterDefinition>
72 <name>PACKER_VERSION</name>
73 <description>Packer version to download and install.</description>
74 <defaultValue>1.1.1</defaultValue>
75 </hudson.model.StringParameterDefinition>
76 </parameterDefinitions>
77 </hudson.model.ParametersDefinitionProperty>
79 <scm class="hudson.plugins.git.GitSCM">
80 <configVersion>2</configVersion>
82 <hudson.plugins.git.UserRemoteConfig>
84 <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
85 <url>git@github.com:example-org/releng/ciman</url>
86 <credentialsId>test-credential</credentialsId>
87 </hudson.plugins.git.UserRemoteConfig>
90 <hudson.plugins.git.BranchSpec>
92 </hudson.plugins.git.BranchSpec>
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"/>
107 <skipTag>true</skipTag>
109 <useShallowClone>false</useShallowClone>
110 <ignoreNotifyCommit>false</ignoreNotifyCommit>
112 <hudson.plugins.git.extensions.impl.SubmoduleOption>
113 <disableSubmodules>false</disableSubmodules>
114 <recursiveSubmodules>true</recursiveSubmodules>
115 <trackingSubmodules>false</trackingSubmodules>
117 <timeout>10</timeout>
118 </hudson.plugins.git.extensions.impl.SubmoduleOption>
119 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
122 <triggers class="vector">
123 <org.jenkinsci.plugins.ghprb.GhprbTrigger>
126 <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
130 <triggerPhrase>^recheck$</triggerPhrase>
131 <onlyTriggerPhrase>false</onlyTriggerPhrase>
132 <useGitHubHooks>true</useGitHubHooks>
133 <permitAll>true</permitAll>
134 <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
136 <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
137 <commitStatusContext>Packer Verify</commitStatusContext>
138 </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
140 </org.jenkinsci.plugins.ghprb.GhprbTrigger>
143 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
145 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
146 <fileId>ci-packer-cloud-env</fileId>
148 <variable>CLOUDENV</variable>
149 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
151 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
154 <propertiesContent>PACKER_VERSION=1.1.1
160 # SPDX-License-Identifier: EPL-1.0
161 ##############################################################################
162 # Copyright (c) 2017 The Linux Foundation and others.
164 # All rights reserved. This program and the accompanying materials
165 # are made available under the terms of the Eclipse Public License v1.0
166 # which accompanies this distribution, and is available at
167 # http://www.eclipse.org/legal/epl-v10.html
168 ##############################################################################
169 echo "---> packer-install.sh"
170 # The script checks for the packer binaries and installs the binary
171 # if its not available
173 # $PACKER_VERSION : Define a packer version passed as job paramter
175 PACKER_VERSION="${PACKER_VERSION:-1.0.2}"
177 # Ensure we fail the job if any steps fail.
180 if hash packer.io 2>/dev/null; then
181 echo "packer.io command is available."
183 echo "packer.io command not is available. Installing packer ..."
184 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
186 wget -nv "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
187 mkdir -p "${WORKSPACE}/bin"
188 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
189 # rename packer to avoid conflict with binary in cracklib
190 mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
195 # SPDX-License-Identifier: EPL-1.0
196 ##############################################################################
197 # Copyright (c) 2017 The Linux Foundation and others.
199 # All rights reserved. This program and the accompanying materials
200 # are made available under the terms of the Eclipse Public License v1.0
201 # which accompanies this distribution, and is available at
202 # http://www.eclipse.org/legal/epl-v10.html
203 ##############################################################################
204 echo "---> packer-validate.sh"
205 # The script validates an packers files.
207 # $CLOUDENV : Provides the cloud credential file.
209 # Ensure we fail the job if any steps fail.
212 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
213 mkdir -p "$PACKER_LOGS_DIR"
214 export PATH="${WORKSPACE}/bin:$PATH"
217 varfiles=(../packer/vars/*.json)
218 templates=(../packer/templates/*.json)
220 for varfile in "${varfiles[@]}"; do
221 for template in "${templates[@]}"; do
222 export PACKER_LOG="yes" && \
223 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log" && \
224 packer.io validate -var-file="$CLOUDENV" \
225 -var-file="$varfile" "$template"
226 if [ $? -ne 0 ]; then
232 </hudson.tasks.Shell>
235 # SPDX-License-Identifier: EPL-1.0
236 ##############################################################################
237 # Copyright (c) 2017 The Linux Foundation and others.
239 # All rights reserved. This program and the accompanying materials
240 # are made available under the terms of the Eclipse Public License v1.0
241 # which accompanies this distribution, and is available at
242 # http://www.eclipse.org/legal/epl-v10.html
243 ##############################################################################
244 echo "---> packer-clear-credentials.sh"
246 set +e # DO NOT cause build failure if any of the rm calls fail.
247 rm "$CLOUDENV"
250 </hudson.tasks.Shell>
253 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
257 # SPDX-License-Identifier: EPL-1.0
258 ##############################################################################
259 # Copyright (c) 2017 The Linux Foundation and others.
261 # All rights reserved. This program and the accompanying materials
262 # are made available under the terms of the Eclipse Public License v1.0
263 # which accompanies this distribution, and is available at
264 # http://www.eclipse.org/legal/epl-v10.html
265 ##############################################################################
266 echo "---> sysstat.sh"
267 set +e # DON'T fail build if script fails.
269 OS=$(facter operatingsystem)
270 case "$OS" in
272 SYSSTAT_PATH="/var/log/sysstat"
274 # Dont run the script when systat is not enabled by default
275 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
280 SYSSTAT_PATH="/var/log/sa"
288 SAR_DIR="$WORKSPACE/archives/sar-reports"
289 mkdir -p "$SAR_DIR"
290 cp "$SYSSTAT_PATH/"* "$_"
291 # convert sar data to ascii format
292 while IFS="" read -r s
294 [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
295 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
297 # DON'T fail build if script fails.
300 </hudson.tasks.Shell>
301 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
303 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
304 <fileId>jenkins-log-archives-settings</fileId>
306 <variable>SETTINGS_FILE</variable>
307 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
309 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
312 <propertiesContent>SERVER_ID=logs</propertiesContent>
317 # SPDX-License-Identifier: EPL-1.0
318 ##############################################################################
319 # Copyright (c) 2017 The Linux Foundation and others.
321 # All rights reserved. This program and the accompanying materials
322 # are made available under the terms of the Eclipse Public License v1.0
323 # which accompanies this distribution, and is available at
324 # http://www.eclipse.org/legal/epl-v10.html
325 ##############################################################################
326 echo "---> create-netrc.sh"
328 # Ensure we fail the job if any steps fail.
331 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
332 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
333 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
334 -v x:username -o ":" -v x:password \
335 "$SETTINGS_FILE")
337 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
338 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
339 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
341 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
343 </hudson.tasks.Shell>
346 # SPDX-License-Identifier: EPL-1.0
347 ##############################################################################
348 # Copyright (c) 2017 The Linux Foundation and others.
350 # All rights reserved. This program and the accompanying materials
351 # are made available under the terms of the Eclipse Public License v1.0
352 # which accompanies this distribution, and is available at
353 # http://www.eclipse.org/legal/epl-v10.html
354 ##############################################################################
355 echo "---> lftools-install.sh"
357 # Script to install lftools via a version passed in via lf-infra-parameters
359 # Required parameters:
361 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
362 # set to a strict version number like '1.2.3' or using
363 # PEP-440 definitions.
367 # >=1.0.0,<2.0.0
369 # By default a released version of lftools should always be used.
370 # The purpose of the 2 variables below is so that lftools devs can test
371 # unreleased versions of lftools. There are 2 methods to install a dev version
374 # 1) gerrit patch: Used to test a patch that has not yet been merged.
375 # To do this set something like this:
376 # LFTOOLS_MODE=gerrit
377 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
379 # 2) git branch: Used to install an lftools version from a specific branch.
380 # To use this set the variables as follows:
382 # LFTOOLS_REFSPEC=master
384 # 3) release : The intended use case and default setting.
385 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
387 LFTOOLS_MODE=release # release | git | gerrit
388 LFTOOLS_REFSPEC=master
390 # Ensure we fail the job if any steps fail.
391 # DO NOT set -u as virtualenv's activate script has unbound variables
394 virtualenv --quiet "/tmp/v/lftools"
395 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
396 source "/tmp/v/lftools/bin/activate"
397 pip install --quiet --upgrade pip
399 case $LFTOOLS_MODE in
401 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
403 git fetch origin "$LFTOOLS_REFSPEC"
404 git checkout FETCH_HEAD
405 pip install --quiet --upgrade -r requirements.txt
406 pip install --quiet --upgrade -e .
411 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
415 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
416 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
419 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
425 # pipdeptree prints out a lot of information because lftools pulls in many
426 # dependencies. Let's only print it if we want to debug.
427 # echo "----> Pip Dependency Tree"
428 # pip install --quiet --upgrade pipdeptree
432 # SPDX-License-Identifier: EPL-1.0
433 ##############################################################################
434 # Copyright (c) 2017 The Linux Foundation and others.
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 "---> logs-deploy.sh"
443 # Ensure we fail the job if any steps fail.
446 set -x # Trace commands for this script to make debugging easier.
448 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
449 LOGS_SERVER="${LOGS_SERVER:-None}"
451 if [ "${LOGS_SERVER}" == 'None' ]
453 set +x # Disable trace since we no longer need it
455 echo "WARNING: Logging server not set"
457 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
458 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
459 BUILD_URL="${BUILD_URL}"
461 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
462 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
464 set +x # Disable trace since we no longer need it.
466 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
469 </hudson.tasks.Shell>
472 # SPDX-License-Identifier: EPL-1.0
473 ##############################################################################
474 # Copyright (c) 2017 The Linux Foundation and others.
476 # All rights reserved. This program and the accompanying materials
477 # are made available under the terms of the Eclipse Public License v1.0
478 # which accompanies this distribution, and is available at
479 # http://www.eclipse.org/legal/epl-v10.html
480 ##############################################################################
482 # Clear log credential files
483 rm "$SETTINGS_FILE"
486 </hudson.tasks.Shell>
487 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
488 <regexp>^Build logs: .*</regexp>
489 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
491 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
492 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
493 <markBuildUnstable>false</markBuildUnstable>
494 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
495 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
497 <hudson.plugins.ws__cleanup.Pattern>
498 <pattern>**/*.jenkins-trigger</pattern>
500 </hudson.plugins.ws__cleanup.Pattern>
502 <deleteDirs>false</deleteDirs>
503 <cleanupMatrixParent>false</cleanupMatrixParent>
505 <cleanWhenSuccess>true</cleanWhenSuccess>
506 <cleanWhenUnstable>true</cleanWhenUnstable>
507 <cleanWhenFailure>true</cleanWhenFailure>
508 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
509 <cleanWhenAborted>true</cleanWhenAborted>
510 <notFailBuild>true</notFailBuild>
511 </hudson.plugins.ws__cleanup.WsCleanup>
514 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
515 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
516 <timeoutMinutes>10</timeoutMinutes>
517 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
518 <failBuild>true</failBuild>
519 <writingDescription>false</writingDescription>
520 <timeoutPercentage>0</timeoutPercentage>
521 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
522 <timeoutType>absolute</timeoutType>
523 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
524 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
525 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
526 <user>test-credential</user>
527 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
528 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
529 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
531 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
532 <fileId>npmrc</fileId>
533 <targetLocation>$HOME/.npmrc</targetLocation>
535 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
537 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>