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.
221 if [[ "$varfile" == *"cloud-env.json"* ]]; then
225 echo "-----> Testing varfile: $varfile"
226 for template in "${templates[@]}"; do
227 export PACKER_LOG="yes"
228 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log"
229 if output=$(packer.io validate -var-file="$CLOUDENV" -var-file="$varfile" "$template"); then
230 echo "$template: $output"
232 echo "$template: $output"
238 </hudson.tasks.Shell>
241 # SPDX-License-Identifier: EPL-1.0
242 ##############################################################################
243 # Copyright (c) 2017 The Linux Foundation and others.
245 # All rights reserved. This program and the accompanying materials
246 # are made available under the terms of the Eclipse Public License v1.0
247 # which accompanies this distribution, and is available at
248 # http://www.eclipse.org/legal/epl-v10.html
249 ##############################################################################
250 echo "---> packer-clear-credentials.sh"
252 set +e # DO NOT cause build failure if any of the rm calls fail.
253 rm "$CLOUDENV"
256 </hudson.tasks.Shell>
259 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
263 # SPDX-License-Identifier: EPL-1.0
264 ##############################################################################
265 # Copyright (c) 2017 The Linux Foundation and others.
267 # All rights reserved. This program and the accompanying materials
268 # are made available under the terms of the Eclipse Public License v1.0
269 # which accompanies this distribution, and is available at
270 # http://www.eclipse.org/legal/epl-v10.html
271 ##############################################################################
272 echo "---> sysstat.sh"
273 set +e # DON'T fail build if script fails.
275 OS=$(facter operatingsystem)
276 case "$OS" in
278 SYSSTAT_PATH="/var/log/sysstat"
280 # Dont run the script when systat is not enabled by default
281 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
286 SYSSTAT_PATH="/var/log/sa"
294 SAR_DIR="$WORKSPACE/archives/sar-reports"
295 mkdir -p "$SAR_DIR"
296 cp "$SYSSTAT_PATH/"* "$_"
297 # convert sar data to ascii format
298 while IFS="" read -r sarfilenum
300 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
301 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
303 # DON'T fail build if script fails.
306 </hudson.tasks.Shell>
307 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
309 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
310 <fileId>jenkins-log-archives-settings</fileId>
312 <variable>SETTINGS_FILE</variable>
313 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
315 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
318 <propertiesContent>SERVER_ID=logs</propertiesContent>
323 # SPDX-License-Identifier: EPL-1.0
324 ##############################################################################
325 # Copyright (c) 2017 The Linux Foundation and others.
327 # All rights reserved. This program and the accompanying materials
328 # are made available under the terms of the Eclipse Public License v1.0
329 # which accompanies this distribution, and is available at
330 # http://www.eclipse.org/legal/epl-v10.html
331 ##############################################################################
332 echo "---> create-netrc.sh"
334 # Ensure we fail the job if any steps fail.
337 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
338 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
339 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
340 -v x:username -o ":" -v x:password \
341 "$SETTINGS_FILE")
343 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
344 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
345 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
347 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
349 </hudson.tasks.Shell>
352 # SPDX-License-Identifier: EPL-1.0
353 ##############################################################################
354 # Copyright (c) 2017 The Linux Foundation and others.
356 # All rights reserved. This program and the accompanying materials
357 # are made available under the terms of the Eclipse Public License v1.0
358 # which accompanies this distribution, and is available at
359 # http://www.eclipse.org/legal/epl-v10.html
360 ##############################################################################
361 echo "---> lftools-install.sh"
363 # Script to install lftools via a version passed in via lf-infra-parameters
365 # Required parameters:
367 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
368 # set to a strict version number like '1.2.3' or using
369 # PEP-440 definitions.
373 # >=1.0.0,<2.0.0
375 # By default a released version of lftools should always be used.
376 # The purpose of the 2 variables below is so that lftools devs can test
377 # unreleased versions of lftools. There are 2 methods to install a dev version
380 # 1) gerrit patch: Used to test a patch that has not yet been merged.
381 # To do this set something like this:
382 # LFTOOLS_MODE=gerrit
383 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
385 # 2) git branch: Used to install an lftools version from a specific branch.
386 # To use this set the variables as follows:
388 # LFTOOLS_REFSPEC=master
390 # 3) release : The intended use case and default setting.
391 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
393 LFTOOLS_MODE=release # release | git | gerrit
394 LFTOOLS_REFSPEC=master
396 # Ensure we fail the job if any steps fail.
397 # DO NOT set -u as virtualenv's activate script has unbound variables
400 virtualenv --quiet "/tmp/v/lftools"
401 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
402 source "/tmp/v/lftools/bin/activate"
403 pip install --quiet --upgrade pip
405 case $LFTOOLS_MODE in
407 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
409 git fetch origin "$LFTOOLS_REFSPEC"
410 git checkout FETCH_HEAD
411 pip install --quiet --upgrade -r requirements.txt
412 pip install --quiet --upgrade -e .
417 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
421 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
422 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
425 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
431 # pipdeptree prints out a lot of information because lftools pulls in many
432 # dependencies. Let's only print it if we want to debug.
433 # echo "----> Pip Dependency Tree"
434 # pip install --quiet --upgrade pipdeptree
438 # SPDX-License-Identifier: EPL-1.0
439 ##############################################################################
440 # Copyright (c) 2017 The Linux Foundation and others.
442 # All rights reserved. This program and the accompanying materials
443 # are made available under the terms of the Eclipse Public License v1.0
444 # which accompanies this distribution, and is available at
445 # http://www.eclipse.org/legal/epl-v10.html
446 ##############################################################################
447 echo "---> logs-deploy.sh"
449 # Ensure we fail the job if any steps fail.
452 set -x # Trace commands for this script to make debugging easier.
454 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
455 LOGS_SERVER="${LOGS_SERVER:-None}"
457 if [ "${LOGS_SERVER}" == 'None' ]
459 set +x # Disable trace since we no longer need it
461 echo "WARNING: Logging server not set"
463 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
464 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
465 BUILD_URL="${BUILD_URL}"
467 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
468 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
470 set +x # Disable trace since we no longer need it.
472 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
475 </hudson.tasks.Shell>
478 # SPDX-License-Identifier: EPL-1.0
479 ##############################################################################
480 # Copyright (c) 2017 The Linux Foundation and others.
482 # All rights reserved. This program and the accompanying materials
483 # are made available under the terms of the Eclipse Public License v1.0
484 # which accompanies this distribution, and is available at
485 # http://www.eclipse.org/legal/epl-v10.html
486 ##############################################################################
488 # Clear log credential files
489 rm "$SETTINGS_FILE"
492 </hudson.tasks.Shell>
493 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
494 <regexp>^Build logs: .*</regexp>
495 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
497 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
498 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
499 <markBuildUnstable>false</markBuildUnstable>
500 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
501 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
503 <hudson.plugins.ws__cleanup.Pattern>
504 <pattern>**/*.jenkins-trigger</pattern>
506 </hudson.plugins.ws__cleanup.Pattern>
508 <deleteDirs>false</deleteDirs>
509 <cleanupMatrixParent>false</cleanupMatrixParent>
511 <cleanWhenSuccess>true</cleanWhenSuccess>
512 <cleanWhenUnstable>true</cleanWhenUnstable>
513 <cleanWhenFailure>true</cleanWhenFailure>
514 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
515 <cleanWhenAborted>true</cleanWhenAborted>
516 <notFailBuild>true</notFailBuild>
517 </hudson.plugins.ws__cleanup.WsCleanup>
520 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
521 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
522 <timeoutMinutes>10</timeoutMinutes>
523 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
524 <failBuild>true</failBuild>
525 <writingDescription>false</writingDescription>
526 <timeoutPercentage>0</timeoutPercentage>
527 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
528 <timeoutType>absolute</timeoutType>
529 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
530 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
531 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
532 <user>test-credential</user>
533 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
534 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
535 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
537 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
538 <fileId>npmrc</fileId>
539 <targetLocation>$HOME/.npmrc</targetLocation>
541 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
543 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>