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.0.2</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.0.2
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.
179 # Default packer binary made available on the build image
180 packer_bin="/usr/local/bin/packer.io"
182 if hash "$packer_bin" 2>/dev/null; then
183 echo "packer.io command is available."
185 echo "packer.io command not is available. Installing packer ..."
186 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
188 wget "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
189 mkdir -p "${WORKSPACE}/bin"
190 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
191 # rename packer to avoid conflict with binary in cracklib
192 mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
197 # SPDX-License-Identifier: EPL-1.0
198 ##############################################################################
199 # Copyright (c) 2017 The Linux Foundation and others.
201 # All rights reserved. This program and the accompanying materials
202 # are made available under the terms of the Eclipse Public License v1.0
203 # which accompanies this distribution, and is available at
204 # http://www.eclipse.org/legal/epl-v10.html
205 ##############################################################################
206 echo "---> packer-validate.sh"
207 # The script validates an packers files.
209 # $CLOUDENV : Provides the cloud credential file.
211 # Ensure we fail the job if any steps fail.
214 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
215 mkdir -p "$PACKER_LOGS_DIR"
216 export PATH="${WORKSPACE}/bin:$PATH"
219 varfiles=(../packer/vars/*.json)
220 templates=(../packer/templates/*.json)
222 for varfile in "${varfiles[@]}"; do
223 for template in "${templates[@]}"; do
224 export PACKER_LOG="yes" && \
225 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log" && \
226 packer.io validate -var-file="$CLOUDENV" \
227 -var-file="$varfile" "$template"
228 if [ $? -ne 0 ]; then
234 </hudson.tasks.Shell>
237 # SPDX-License-Identifier: EPL-1.0
238 ##############################################################################
239 # Copyright (c) 2017 The Linux Foundation and others.
241 # All rights reserved. This program and the accompanying materials
242 # are made available under the terms of the Eclipse Public License v1.0
243 # which accompanies this distribution, and is available at
244 # http://www.eclipse.org/legal/epl-v10.html
245 ##############################################################################
246 echo "---> packer-clear-credentials.sh"
248 set +e # DO NOT cause build failure if any of the rm calls fail.
249 rm "$CLOUDENV"
252 </hudson.tasks.Shell>
255 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
259 # SPDX-License-Identifier: EPL-1.0
260 ##############################################################################
261 # Copyright (c) 2017 The Linux Foundation and others.
263 # All rights reserved. This program and the accompanying materials
264 # are made available under the terms of the Eclipse Public License v1.0
265 # which accompanies this distribution, and is available at
266 # http://www.eclipse.org/legal/epl-v10.html
267 ##############################################################################
268 echo "---> sysstat.sh"
269 set +e # DON'T fail build if script fails.
271 OS=$(facter operatingsystem)
272 case "$OS" in
274 SYSSTAT_PATH="/var/log/sysstat"
276 # Dont run the script when systat is not enabled by default
277 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
282 SYSSTAT_PATH="/var/log/sa"
290 SAR_DIR="$WORKSPACE/archives/sar-reports"
291 mkdir -p "$SAR_DIR"
292 cp "$SYSSTAT_PATH/"* "$_"
293 # convert sar data to ascii format
294 while IFS="" read -r s
296 [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
297 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
299 # DON'T fail build if script fails.
302 </hudson.tasks.Shell>
303 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
305 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
306 <fileId>jenkins-log-archives-settings</fileId>
308 <variable>SETTINGS_FILE</variable>
309 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
311 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
314 <propertiesContent>SERVER_ID=logs</propertiesContent>
319 # SPDX-License-Identifier: EPL-1.0
320 ##############################################################################
321 # Copyright (c) 2017 The Linux Foundation and others.
323 # All rights reserved. This program and the accompanying materials
324 # are made available under the terms of the Eclipse Public License v1.0
325 # which accompanies this distribution, and is available at
326 # http://www.eclipse.org/legal/epl-v10.html
327 ##############################################################################
328 echo "---> create-netrc.sh"
330 # Ensure we fail the job if any steps fail.
333 NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
334 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
335 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
336 -v x:username -o ":" -v x:password \
337 "$SETTINGS_FILE")
339 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
340 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
341 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
343 echo "machine $machine login $user password $pass" > ~/.netrc
345 </hudson.tasks.Shell>
348 # SPDX-License-Identifier: EPL-1.0
349 ##############################################################################
350 # Copyright (c) 2017 The Linux Foundation and others.
352 # All rights reserved. This program and the accompanying materials
353 # are made available under the terms of the Eclipse Public License v1.0
354 # which accompanies this distribution, and is available at
355 # http://www.eclipse.org/legal/epl-v10.html
356 ##############################################################################
357 echo "---> lftools-install.sh"
359 # Script to install lftools via a version passed in via lf-infra-parameters
361 # Required parameters:
363 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
364 # set to a strict version number like '1.2.3' or using
365 # PEP-440 definitions.
369 # >=1.0.0,<2.0.0
371 # By default a released version of lftools should always be used.
372 # The purpose of the 2 variables below is so that lftools devs can test
373 # unreleased versions of lftools. There are 2 methods to install a dev version
376 # 1) gerrit patch: Used to test a patch that has not yet been merged.
377 # To do this set something like this:
378 # LFTOOLS_MODE=gerrit
379 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
381 # 2) git branch: Used to install an lftools version from a specific branch.
382 # To use this set the variables as follows:
384 # LFTOOLS_REFSPEC=master
386 # 3) release : The intended use case and default setting.
387 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
389 LFTOOLS_MODE=release # release | git | gerrit
390 LFTOOLS_REFSPEC=master
392 # Ensure we fail the job if any steps fail.
393 # DO NOT set -u as virtualenv's activate script has unbound variables
396 virtualenv --quiet "/tmp/v/lftools"
397 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
398 source "/tmp/v/lftools/bin/activate"
399 pip install --quiet --upgrade pip
401 case $LFTOOLS_MODE in
403 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
405 git fetch origin "$LFTOOLS_REFSPEC"
406 git checkout FETCH_HEAD
407 pip install --quiet --upgrade -r requirements.txt
408 pip install --quiet --upgrade -e .
413 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
417 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
418 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
421 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
427 # pipdeptree prints out a lot of information because lftools pulls in many
428 # dependencies. Let's only print it if we want to debug.
429 # echo "----> Pip Dependency Tree"
430 # pip install --quiet --upgrade pipdeptree
434 # SPDX-License-Identifier: EPL-1.0
435 ##############################################################################
436 # Copyright (c) 2017 The Linux Foundation and others.
438 # All rights reserved. This program and the accompanying materials
439 # are made available under the terms of the Eclipse Public License v1.0
440 # which accompanies this distribution, and is available at
441 # http://www.eclipse.org/legal/epl-v10.html
442 ##############################################################################
443 echo "---> logs-deploy.sh"
445 # Ensure we fail the job if any steps fail.
448 set -x # Trace commands for this script to make debugging easier.
450 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
451 LOGS_SERVER="${LOGS_SERVER:-None}"
453 if [ "${LOGS_SERVER}" == 'None' ]
455 set +x # Disable trace since we no longer need it
457 echo "WARNING: Logging server not set"
459 NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
460 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
461 BUILD_URL="${BUILD_URL}"
463 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
464 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
466 set +x # Disable trace since we no longer need it.
468 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
471 </hudson.tasks.Shell>
474 # SPDX-License-Identifier: EPL-1.0
475 ##############################################################################
476 # Copyright (c) 2017 The Linux Foundation and others.
478 # All rights reserved. This program and the accompanying materials
479 # are made available under the terms of the Eclipse Public License v1.0
480 # which accompanies this distribution, and is available at
481 # http://www.eclipse.org/legal/epl-v10.html
482 ##############################################################################
484 # Clear log credential files
485 rm "$SETTINGS_FILE"
488 </hudson.tasks.Shell>
489 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
490 <regexp>^Build logs: .*</regexp>
491 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
493 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
494 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
495 <markBuildUnstable>false</markBuildUnstable>
496 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
497 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
499 <hudson.plugins.ws__cleanup.Pattern>
500 <pattern>**/*.jenkins-trigger</pattern>
502 </hudson.plugins.ws__cleanup.Pattern>
504 <deleteDirs>false</deleteDirs>
505 <cleanupMatrixParent>false</cleanupMatrixParent>
507 <cleanWhenSuccess>true</cleanWhenSuccess>
508 <cleanWhenUnstable>true</cleanWhenUnstable>
509 <cleanWhenFailure>true</cleanWhenFailure>
510 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
511 <cleanWhenAborted>true</cleanWhenAborted>
512 <notFailBuild>true</notFailBuild>
513 </hudson.plugins.ws__cleanup.WsCleanup>
516 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
517 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
518 <timeoutMinutes>10</timeoutMinutes>
519 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
520 <failBuild>true</failBuild>
521 <writingDescription>false</writingDescription>
522 <timeoutPercentage>0</timeoutPercentage>
523 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
524 <timeoutType>absolute</timeoutType>
525 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
526 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
527 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
528 <user>test-credential</user>
529 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
530 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>