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.3</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.3
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.1.3}"
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=(vars/*.json common-packer/vars/*.json)
218 templates=(templates/*.json)
220 for varfile in "${varfiles[@]}"; do
221 # cloud-env.json is a file containing credentials which is pulled in via
222 # CLOUDENV variable so skip it here.
223 if [[ "$varfile" == *"cloud-env.json"* ]]; then
227 echo "-----> Testing varfile: $varfile"
228 for template in "${templates[@]}"; do
229 export PACKER_LOG="yes"
230 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log"
231 if output=$(packer.io validate -var-file="$CLOUDENV" -var-file="$varfile" "$template"); then
232 echo "$template: $output"
234 echo "$template: $output"
240 </hudson.tasks.Shell>
243 # SPDX-License-Identifier: EPL-1.0
244 ##############################################################################
245 # Copyright (c) 2017 The Linux Foundation and others.
247 # All rights reserved. This program and the accompanying materials
248 # are made available under the terms of the Eclipse Public License v1.0
249 # which accompanies this distribution, and is available at
250 # http://www.eclipse.org/legal/epl-v10.html
251 ##############################################################################
252 echo "---> packer-clear-credentials.sh"
254 set +e # DO NOT cause build failure if any of the rm calls fail.
255 rm "$CLOUDENV"
258 </hudson.tasks.Shell>
261 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
265 # SPDX-License-Identifier: EPL-1.0
266 ##############################################################################
267 # Copyright (c) 2017 The Linux Foundation and others.
269 # All rights reserved. This program and the accompanying materials
270 # are made available under the terms of the Eclipse Public License v1.0
271 # which accompanies this distribution, and is available at
272 # http://www.eclipse.org/legal/epl-v10.html
273 ##############################################################################
274 echo "---> sysstat.sh"
275 set +e # DON'T fail build if script fails.
277 OS=$(facter operatingsystem)
278 case "$OS" in
280 SYSSTAT_PATH="/var/log/sysstat"
282 # Dont run the script when systat is not enabled by default
283 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
288 SYSSTAT_PATH="/var/log/sa"
296 SAR_DIR="$WORKSPACE/archives/sar-reports"
297 mkdir -p "$SAR_DIR"
298 cp "$SYSSTAT_PATH/"* "$_"
299 # convert sar data to ascii format
300 while IFS="" read -r sarfilenum
302 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
303 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
305 # DON'T fail build if script fails.
308 </hudson.tasks.Shell>
309 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
311 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
312 <fileId>jenkins-log-archives-settings</fileId>
314 <variable>SETTINGS_FILE</variable>
315 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
317 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
320 <propertiesContent>SERVER_ID=logs</propertiesContent>
325 # SPDX-License-Identifier: EPL-1.0
326 ##############################################################################
327 # Copyright (c) 2017 The Linux Foundation and others.
329 # All rights reserved. This program and the accompanying materials
330 # are made available under the terms of the Eclipse Public License v1.0
331 # which accompanies this distribution, and is available at
332 # http://www.eclipse.org/legal/epl-v10.html
333 ##############################################################################
334 echo "---> create-netrc.sh"
336 # Ensure we fail the job if any steps fail.
339 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
340 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
341 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
342 -v x:username -o ":" -v x:password \
343 "$SETTINGS_FILE")
345 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
346 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
347 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
349 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
351 </hudson.tasks.Shell>
354 # SPDX-License-Identifier: EPL-1.0
355 ##############################################################################
356 # Copyright (c) 2017 The Linux Foundation and others.
358 # All rights reserved. This program and the accompanying materials
359 # are made available under the terms of the Eclipse Public License v1.0
360 # which accompanies this distribution, and is available at
361 # http://www.eclipse.org/legal/epl-v10.html
362 ##############################################################################
363 echo "---> lftools-install.sh"
365 # Script to install lftools via a version passed in via lf-infra-parameters
367 # Required parameters:
369 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
370 # set to a strict version number like '1.2.3' or using
371 # PEP-440 definitions.
375 # >=1.0.0,<2.0.0
377 # By default a released version of lftools should always be used.
378 # The purpose of the 2 variables below is so that lftools devs can test
379 # unreleased versions of lftools. There are 2 methods to install a dev version
382 # 1) gerrit patch: Used to test a patch that has not yet been merged.
383 # To do this set something like this:
384 # LFTOOLS_MODE=gerrit
385 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
387 # 2) git branch: Used to install an lftools version from a specific branch.
388 # To use this set the variables as follows:
390 # LFTOOLS_REFSPEC=master
392 # 3) release : The intended use case and default setting.
393 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
395 LFTOOLS_MODE=release # release | git | gerrit
396 LFTOOLS_REFSPEC=master
398 # Ensure we fail the job if any steps fail.
399 # DO NOT set -u as virtualenv's activate script has unbound variables
402 virtualenv --quiet "/tmp/v/lftools"
403 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
404 source "/tmp/v/lftools/bin/activate"
405 pip install --quiet --upgrade pip
407 case $LFTOOLS_MODE in
409 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
411 git fetch origin "$LFTOOLS_REFSPEC"
412 git checkout FETCH_HEAD
413 pip install --quiet --upgrade -r requirements.txt
414 pip install --quiet --upgrade -e .
419 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
423 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
424 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
427 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
433 # pipdeptree prints out a lot of information because lftools pulls in many
434 # dependencies. Let's only print it if we want to debug.
435 # echo "----> Pip Dependency Tree"
436 # pip install --quiet --upgrade pipdeptree
440 # SPDX-License-Identifier: EPL-1.0
441 ##############################################################################
442 # Copyright (c) 2017 The Linux Foundation and others.
444 # All rights reserved. This program and the accompanying materials
445 # are made available under the terms of the Eclipse Public License v1.0
446 # which accompanies this distribution, and is available at
447 # http://www.eclipse.org/legal/epl-v10.html
448 ##############################################################################
449 echo "---> logs-deploy.sh"
451 # Ensure we fail the job if any steps fail.
454 set -x # Trace commands for this script to make debugging easier.
456 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
457 LOGS_SERVER="${LOGS_SERVER:-None}"
459 if [ "${LOGS_SERVER}" == 'None' ]
461 set +x # Disable trace since we no longer need it
463 echo "WARNING: Logging server not set"
465 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
466 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
467 BUILD_URL="${BUILD_URL}"
469 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
470 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
472 set +x # Disable trace since we no longer need it.
474 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
477 </hudson.tasks.Shell>
480 # SPDX-License-Identifier: EPL-1.0
481 ##############################################################################
482 # Copyright (c) 2017 The Linux Foundation and others.
484 # All rights reserved. This program and the accompanying materials
485 # are made available under the terms of the Eclipse Public License v1.0
486 # which accompanies this distribution, and is available at
487 # http://www.eclipse.org/legal/epl-v10.html
488 ##############################################################################
490 # Clear log credential files
491 rm "$SETTINGS_FILE"
494 </hudson.tasks.Shell>
495 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
496 <regexp>^Build logs: .*</regexp>
497 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
499 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
500 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
501 <markBuildUnstable>false</markBuildUnstable>
502 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
503 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
505 <hudson.plugins.ws__cleanup.Pattern>
506 <pattern>**/*.jenkins-trigger</pattern>
508 </hudson.plugins.ws__cleanup.Pattern>
510 <deleteDirs>false</deleteDirs>
511 <cleanupMatrixParent>false</cleanupMatrixParent>
513 <cleanWhenSuccess>true</cleanWhenSuccess>
514 <cleanWhenUnstable>true</cleanWhenUnstable>
515 <cleanWhenFailure>true</cleanWhenFailure>
516 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
517 <cleanWhenAborted>true</cleanWhenAborted>
518 <notFailBuild>true</notFailBuild>
519 </hudson.plugins.ws__cleanup.WsCleanup>
522 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
523 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
524 <timeoutMinutes>10</timeoutMinutes>
525 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
526 <failBuild>true</failBuild>
527 <writingDescription>false</writingDescription>
528 <timeoutPercentage>0</timeoutPercentage>
529 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
530 <timeoutType>absolute</timeoutType>
531 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
532 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
533 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
534 <user>test-credential</user>
535 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
536 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
537 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
539 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
540 <fileId>npmrc</fileId>
541 <targetLocation>$HOME/.npmrc</targetLocation>
543 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
545 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>