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 plugin="github">
13 <projectUrl>https://github.com/example-org/releng/ciman</projectUrl>
15 </com.coravy.hudson.plugins.github.GithubProjectProperty>
16 <hudson.model.ParametersDefinitionProperty>
17 <parameterDefinitions>
18 <hudson.model.StringParameterDefinition>
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
24 <defaultValue>releng/ciman</defaultValue>
25 </hudson.model.StringParameterDefinition>
26 <hudson.model.StringParameterDefinition>
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
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
40 Note that Gerrit will override this parameter automatically if a
41 job is triggered by Gerrit.
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.
49 Note that Gerrit will override this parameter automatically if a
50 job is triggered by Gerrit.
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.
58 Note that Gerrit will override this parameter automatically if a
59 job is triggered by Gerrit.
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 '<1.0.0' or '>=1.0.0,<2.0.0'.
70 <defaultValue><1.0.0</defaultValue>
71 </hudson.model.StringParameterDefinition>
72 <hudson.model.StringParameterDefinition>
73 <name>PACKER_VERSION</name>
74 <description>Packer version to download and install.</description>
75 <defaultValue>1.1.3</defaultValue>
76 </hudson.model.StringParameterDefinition>
77 </parameterDefinitions>
78 </hudson.model.ParametersDefinitionProperty>
80 <scm class="hudson.plugins.git.GitSCM">
81 <configVersion>2</configVersion>
83 <hudson.plugins.git.UserRemoteConfig>
85 <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
86 <url>git@github.com:example-org/releng/ciman</url>
87 <credentialsId>test-credential</credentialsId>
88 </hudson.plugins.git.UserRemoteConfig>
91 <hudson.plugins.git.BranchSpec>
93 </hudson.plugins.git.BranchSpec>
95 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
96 <remotePoll>false</remotePoll>
97 <gitTool>Default</gitTool>
98 <submoduleCfg class="list"/>
103 <hudson.plugins.git.extensions.impl.BuildChooserSetting>
104 <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
105 </hudson.plugins.git.extensions.impl.BuildChooserSetting>
106 <hudson.plugins.git.extensions.impl.SubmoduleOption>
107 <disableSubmodules>false</disableSubmodules>
108 <recursiveSubmodules>true</recursiveSubmodules>
109 <trackingSubmodules>false</trackingSubmodules>
110 <parentCredentials>false</parentCredentials>
112 <timeout>10</timeout>
113 </hudson.plugins.git.extensions.impl.SubmoduleOption>
114 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
117 <triggers class="vector">
118 <org.jenkinsci.plugins.ghprb.GhprbTrigger>
121 <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
127 <triggerPhrase>^recheck$</triggerPhrase>
129 <onlyTriggerPhrase>false</onlyTriggerPhrase>
130 <useGitHubHooks>true</useGitHubHooks>
131 <permitAll>true</permitAll>
132 <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
134 <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
135 <commitStatusContext>Packer Verify</commitStatusContext>
136 </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
138 </org.jenkinsci.plugins.ghprb.GhprbTrigger>
141 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
143 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
144 <fileId>ci-packer-cloud-env</fileId>
146 <variable>CLOUDENV</variable>
147 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
149 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
152 <propertiesContent>PACKER_VERSION=1.1.3
158 # SPDX-License-Identifier: EPL-1.0
159 ##############################################################################
160 # Copyright (c) 2017 The Linux Foundation and others.
162 # All rights reserved. This program and the accompanying materials
163 # are made available under the terms of the Eclipse Public License v1.0
164 # which accompanies this distribution, and is available at
165 # http://www.eclipse.org/legal/epl-v10.html
166 ##############################################################################
167 echo "---> packer-install.sh"
168 # The script checks for the packer binaries and installs the binary
169 # if its not available
171 # $PACKER_VERSION : Define a packer version passed as job paramter
173 PACKER_VERSION="${PACKER_VERSION:-1.1.3}"
175 # Ensure we fail the job if any steps fail.
178 if hash packer.io 2>/dev/null; then
179 echo "packer.io command is available."
181 echo "packer.io command not is available. Installing packer ..."
182 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
183 pushd "${WORKSPACE}"
184 wget -nv "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
185 mkdir -p "${WORKSPACE}/bin"
186 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d "${WORKSPACE}/bin/"
187 # rename packer to avoid conflict with binary in cracklib
188 mv "${WORKSPACE}/bin/packer" "${WORKSPACE}/bin/packer.io"
193 # SPDX-License-Identifier: EPL-1.0
194 ##############################################################################
195 # Copyright (c) 2017 The Linux Foundation and others.
197 # All rights reserved. This program and the accompanying materials
198 # are made available under the terms of the Eclipse Public License v1.0
199 # which accompanies this distribution, and is available at
200 # http://www.eclipse.org/legal/epl-v10.html
201 ##############################################################################
202 echo "---> packer-validate.sh"
203 # The script validates an packers files.
205 # $CLOUDENV : Provides the cloud credential file.
207 # Ensure we fail the job if any steps fail.
210 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
211 mkdir -p "$PACKER_LOGS_DIR"
212 export PATH="${WORKSPACE}/bin:$PATH"
215 varfiles=(vars/*.json common-packer/vars/*.json)
216 templates=(templates/*.json)
218 for varfile in "${varfiles[@]}"; do
219 # cloud-env.json is a file containing credentials which is pulled in via
220 # CLOUDENV variable so skip it here. Also handle the case where a project
221 # has not vars/*.json file.
222 if [[ "$varfile" == *"cloud-env.json"* ]] || [[ "$varfile" == 'vars/*.json' ]]; then
226 echo "-----> Testing varfile: $varfile"
227 for template in "${templates[@]}"; do
228 export PACKER_LOG="yes"
229 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log"
230 if output=$(packer.io validate -var-file="$CLOUDENV" -var-file="$varfile" "$template"); then
231 echo "$template: $output"
233 echo "$template: $output"
239 </hudson.tasks.Shell>
242 # SPDX-License-Identifier: EPL-1.0
243 ##############################################################################
244 # Copyright (c) 2017 The Linux Foundation and others.
246 # All rights reserved. This program and the accompanying materials
247 # are made available under the terms of the Eclipse Public License v1.0
248 # which accompanies this distribution, and is available at
249 # http://www.eclipse.org/legal/epl-v10.html
250 ##############################################################################
251 echo "---> packer-clear-credentials.sh"
253 set +e # DO NOT cause build failure if any of the rm calls fail.
254 rm "$CLOUDENV"
257 </hudson.tasks.Shell>
260 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
264 # SPDX-License-Identifier: EPL-1.0
265 ##############################################################################
266 # Copyright (c) 2017 The Linux Foundation and others.
268 # All rights reserved. This program and the accompanying materials
269 # are made available under the terms of the Eclipse Public License v1.0
270 # which accompanies this distribution, and is available at
271 # http://www.eclipse.org/legal/epl-v10.html
272 ##############################################################################
273 echo "---> sysstat.sh"
274 set +e # DON'T fail build if script fails.
276 OS=$(facter operatingsystem)
277 case "$OS" in
279 SYSSTAT_PATH="/var/log/sysstat"
281 # Dont run the script when systat is not enabled by default
282 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
287 SYSSTAT_PATH="/var/log/sa"
295 SAR_DIR="$WORKSPACE/archives/sar-reports"
296 mkdir -p "$SAR_DIR"
297 cp "$SYSSTAT_PATH/"* "$_"
298 # convert sar data to ascii format
299 while IFS="" read -r sarfilenum
301 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
302 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
304 # DON'T fail build if script fails.
307 </hudson.tasks.Shell>
308 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
310 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
311 <fileId>jenkins-log-archives-settings</fileId>
313 <variable>SETTINGS_FILE</variable>
314 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
316 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
319 <propertiesContent>SERVER_ID=logs</propertiesContent>
324 # SPDX-License-Identifier: EPL-1.0
325 ##############################################################################
326 # Copyright (c) 2017 The Linux Foundation and others.
328 # All rights reserved. This program and the accompanying materials
329 # are made available under the terms of the Eclipse Public License v1.0
330 # which accompanies this distribution, and is available at
331 # http://www.eclipse.org/legal/epl-v10.html
332 ##############################################################################
333 echo "---> create-netrc.sh"
335 # Ensure we fail the job if any steps fail.
338 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
339 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
340 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
341 -v x:username -o ":" -v x:password \
342 "$SETTINGS_FILE")
344 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
345 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
346 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
348 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
350 </hudson.tasks.Shell>
353 # SPDX-License-Identifier: EPL-1.0
354 ##############################################################################
355 # Copyright (c) 2017 The Linux Foundation and others.
357 # All rights reserved. This program and the accompanying materials
358 # are made available under the terms of the Eclipse Public License v1.0
359 # which accompanies this distribution, and is available at
360 # http://www.eclipse.org/legal/epl-v10.html
361 ##############################################################################
362 echo "---> lftools-install.sh"
364 # Script to install lftools via a version passed in via lf-infra-parameters
366 # Required parameters:
368 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
369 # set to a strict version number like '1.2.3' or using
370 # PEP-440 definitions.
374 # >=1.0.0,<2.0.0
376 # By default a released version of lftools should always be used.
377 # The purpose of the 2 variables below is so that lftools devs can test
378 # unreleased versions of lftools. There are 2 methods to install a dev version
381 # 1) gerrit patch: Used to test a patch that has not yet been merged.
382 # To do this set something like this:
383 # LFTOOLS_MODE=gerrit
384 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
386 # 2) git branch: Used to install an lftools version from a specific branch.
387 # To use this set the variables as follows:
389 # LFTOOLS_REFSPEC=master
391 # 3) release : The intended use case and default setting.
392 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
394 LFTOOLS_MODE=release # release | git | gerrit
395 LFTOOLS_REFSPEC=master
397 # Ensure we fail the job if any steps fail.
398 # DO NOT set -u as virtualenv's activate script has unbound variables
401 virtualenv --quiet "/tmp/v/lftools"
402 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
403 source "/tmp/v/lftools/bin/activate"
404 pip install --quiet --upgrade pip
406 case $LFTOOLS_MODE in
408 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
410 git fetch origin "$LFTOOLS_REFSPEC"
411 git checkout FETCH_HEAD
412 pip install --quiet --upgrade -r requirements.txt
413 pip install --quiet --upgrade -e .
418 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
422 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
423 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
426 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
432 # pipdeptree prints out a lot of information because lftools pulls in many
433 # dependencies. Let's only print it if we want to debug.
434 # echo "----> Pip Dependency Tree"
435 # pip install --quiet --upgrade pipdeptree
439 # SPDX-License-Identifier: EPL-1.0
440 ##############################################################################
441 # Copyright (c) 2017 The Linux Foundation and others.
443 # All rights reserved. This program and the accompanying materials
444 # are made available under the terms of the Eclipse Public License v1.0
445 # which accompanies this distribution, and is available at
446 # http://www.eclipse.org/legal/epl-v10.html
447 ##############################################################################
448 echo "---> logs-deploy.sh"
450 # Ensure we fail the job if any steps fail.
453 set -x # Trace commands for this script to make debugging easier.
455 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
456 LOGS_SERVER="${LOGS_SERVER:-None}"
458 if [ "${LOGS_SERVER}" == 'None' ]
460 set +x # Disable trace since we no longer need it
462 echo "WARNING: Logging server not set"
464 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
465 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
466 BUILD_URL="${BUILD_URL}"
468 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
469 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
471 set +x # Disable trace since we no longer need it.
473 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
476 </hudson.tasks.Shell>
479 # SPDX-License-Identifier: EPL-1.0
480 ##############################################################################
481 # Copyright (c) 2017 The Linux Foundation and others.
483 # All rights reserved. This program and the accompanying materials
484 # are made available under the terms of the Eclipse Public License v1.0
485 # which accompanies this distribution, and is available at
486 # http://www.eclipse.org/legal/epl-v10.html
487 ##############################################################################
489 # Clear log credential files
490 rm "$SETTINGS_FILE"
493 </hudson.tasks.Shell>
494 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
495 <regexp>^Build logs: .*</regexp>
496 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
498 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
499 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
500 <markBuildUnstable>false</markBuildUnstable>
501 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
502 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
504 <hudson.plugins.ws__cleanup.Pattern>
505 <pattern>**/*.jenkins-trigger</pattern>
507 </hudson.plugins.ws__cleanup.Pattern>
509 <deleteDirs>false</deleteDirs>
510 <cleanupMatrixParent>false</cleanupMatrixParent>
512 <cleanWhenSuccess>true</cleanWhenSuccess>
513 <cleanWhenUnstable>true</cleanWhenUnstable>
514 <cleanWhenFailure>true</cleanWhenFailure>
515 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
516 <cleanWhenAborted>true</cleanWhenAborted>
517 <notFailBuild>true</notFailBuild>
518 </hudson.plugins.ws__cleanup.WsCleanup>
521 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
522 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
523 <timeoutMinutes>10</timeoutMinutes>
524 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
525 <failBuild>true</failBuild>
526 <writingDescription>false</writingDescription>
527 <timeoutPercentage>0</timeoutPercentage>
528 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
529 <timeoutType>absolute</timeoutType>
530 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
531 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
532 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
533 <user>test-credential</user>
534 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
535 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
536 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
538 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
539 <fileId>npmrc</fileId>
540 <targetLocation>$HOME/.npmrc</targetLocation>
542 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
544 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>