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.
61 </hudson.model.StringParameterDefinition>
62 <hudson.model.StringParameterDefinition>
63 <name>PACKER_VERSION</name>
64 <description>Packer version to download and install.</description>
65 <defaultValue>1.0.2</defaultValue>
66 </hudson.model.StringParameterDefinition>
67 </parameterDefinitions>
68 </hudson.model.ParametersDefinitionProperty>
70 <scm class="hudson.plugins.git.GitSCM">
71 <configVersion>2</configVersion>
73 <hudson.plugins.git.UserRemoteConfig>
76 <url>git@github.com:example-org/releng/ciman</url>
77 <credentialsId>test-credential</credentialsId>
78 </hudson.plugins.git.UserRemoteConfig>
81 <hudson.plugins.git.BranchSpec>
83 </hudson.plugins.git.BranchSpec>
86 <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
87 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
88 <authorOrCommitter>false</authorOrCommitter>
89 <wipeOutWorkspace>true</wipeOutWorkspace>
90 <pruneBranches>false</pruneBranches>
91 <remotePoll>false</remotePoll>
92 <gitTool>Default</gitTool>
93 <submoduleCfg class="list"/>
98 <skipTag>true</skipTag>
100 <useShallowClone>false</useShallowClone>
101 <ignoreNotifyCommit>false</ignoreNotifyCommit>
103 <hudson.plugins.git.extensions.impl.SubmoduleOption>
104 <disableSubmodules>false</disableSubmodules>
105 <recursiveSubmodules>true</recursiveSubmodules>
106 <trackingSubmodules>false</trackingSubmodules>
108 <timeout>10</timeout>
109 </hudson.plugins.git.extensions.impl.SubmoduleOption>
110 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
113 <triggers class="vector">
114 <hudson.triggers.TimerTrigger>
115 <spec>00 10 1 * *</spec>
116 </hudson.triggers.TimerTrigger>
117 <com.cloudbees.jenkins.GitHubPushTrigger>
119 </com.cloudbees.jenkins.GitHubPushTrigger>
120 <hudson.triggers.SCMTrigger>
122 <ignorePostCommitHooks>false</ignorePostCommitHooks>
123 </hudson.triggers.SCMTrigger>
124 <org.jenkinsci.plugins.ghprb.GhprbTrigger>
126 <adminlist>tykeal</adminlist>
127 <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
131 <orgslist>example-org</orgslist>
133 <triggerPhrase>^remerge$</triggerPhrase>
134 <onlyTriggerPhrase>true</onlyTriggerPhrase>
135 <useGitHubHooks>true</useGitHubHooks>
136 <permitAll>false</permitAll>
137 <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
139 <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
140 <commitStatusContext>Packer ubuntu1604-$mininet Merge</commitStatusContext>
141 </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
143 </org.jenkinsci.plugins.ghprb.GhprbTrigger>
146 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
148 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
149 <fileId>ci-packer-cloud-env</fileId>
151 <variable>CLOUDENV</variable>
152 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
154 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
157 <propertiesContent>PACKER_VERSION=1.0.2
163 # SPDX-License-Identifier: EPL-1.0
164 ##############################################################################
165 # Copyright (c) 2017 The Linux Foundation and others.
167 # All rights reserved. This program and the accompanying materials
168 # are made available under the terms of the Eclipse Public License v1.0
169 # which accompanies this distribution, and is available at
170 # http://www.eclipse.org/legal/epl-v10.html
171 ##############################################################################
172 echo "---> packer-install.sh"
173 # The script checks for the packer binaries and installs the binary
174 # if its not available
176 # $PACKER_VERSION : Define a packer version passed as job paramter
178 PACKER_VERSION="${PACKER_VERSION:-1.0.2}"
180 # Ensure we fail the job if any steps fail.
182 # Default packer binary made available on the build image
183 packer_bin="/usr/local/bin/packer.io"
185 if hash "$packer_bin" 2>/dev/null; then
186 echo "packer.io command is available."
188 echo "packer.io command not is available. Installing packer ..."
189 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
191 wget "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
192 mkdir -p "${WORKSPACE}/bin"
193 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
194 # rename packer to avoid conflict with binary in cracklib
195 mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
200 # SPDX-License-Identifier: EPL-1.0
201 ##############################################################################
202 # Copyright (c) 2017 The Linux Foundation and others.
204 # All rights reserved. This program and the accompanying materials
205 # are made available under the terms of the Eclipse Public License v1.0
206 # which accompanies this distribution, and is available at
207 # http://www.eclipse.org/legal/epl-v10.html
208 ##############################################################################
209 echo "---> packer-validate.sh"
210 # The script validates an packers files.
212 # $CLOUDENV : Provides the cloud credential file.
214 # Ensure we fail the job if any steps fail.
217 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
218 mkdir -p "$PACKER_LOGS_DIR"
219 export PATH="${WORKSPACE}/bin:$PATH"
222 varfiles=(../packer/vars/*.json)
223 templates=(../packer/templates/*.json)
225 for varfile in "${varfiles[@]}"; do
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 packer.io validate -var-file="$CLOUDENV" \
230 -var-file="$varfile" "$template"
231 if [ $? -ne 0 ]; then
237 </hudson.tasks.Shell>
240 # SPDX-License-Identifier: EPL-1.0
241 ##############################################################################
242 # Copyright (c) 2017 The Linux Foundation and others.
244 # All rights reserved. This program and the accompanying materials
245 # are made available under the terms of the Eclipse Public License v1.0
246 # which accompanies this distribution, and is available at
247 # http://www.eclipse.org/legal/epl-v10.html
248 ##############################################################################
249 echo "---> packer-clear-credentials.sh"
251 set +e # DO NOT cause build failure if any of the rm calls fail.
252 rm "$CLOUDENV"
255 </hudson.tasks.Shell>
256 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
258 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
259 <fileId>ci-packer-cloud-env</fileId>
261 <variable>CLOUDENV</variable>
262 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
264 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
267 <propertiesContent>PACKER_PLATFORM=ubuntu1604
268 PACKER_TEMPLATE=mininet
275 # SPDX-License-Identifier: EPL-1.0
276 ##############################################################################
277 # Copyright (c) 2017 The Linux Foundation and others.
279 # All rights reserved. This program and the accompanying materials
280 # are made available under the terms of the Eclipse Public License v1.0
281 # which accompanies this distribution, and is available at
282 # http://www.eclipse.org/legal/epl-v10.html
283 ##############################################################################
284 echo "---> packer-install.sh"
285 # The script checks for the packer binaries and installs the binary
286 # if its not available
288 # $PACKER_VERSION : Define a packer version passed as job paramter
290 PACKER_VERSION="${PACKER_VERSION:-1.0.2}"
292 # Ensure we fail the job if any steps fail.
294 # Default packer binary made available on the build image
295 packer_bin="/usr/local/bin/packer.io"
297 if hash "$packer_bin" 2>/dev/null; then
298 echo "packer.io command is available."
300 echo "packer.io command not is available. Installing packer ..."
301 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
303 wget "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
304 mkdir -p "${WORKSPACE}/bin"
305 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
306 # rename packer to avoid conflict with binary in cracklib
307 mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
312 # SPDX-License-Identifier: EPL-1.0
313 ##############################################################################
314 # Copyright (c) 2017 The Linux Foundation and others.
316 # All rights reserved. This program and the accompanying materials
317 # are made available under the terms of the Eclipse Public License v1.0
318 # which accompanies this distribution, and is available at
319 # http://www.eclipse.org/legal/epl-v10.html
320 ##############################################################################
321 echo "---> packer-build.sh"
322 # The script builds an image using packer
323 # $CLOUDENV : Provides the cloud credential file.
324 # $PACKER_PLATFORM : Provides the packer platform.
325 # $PACKER_TEMPLATE : Provides the packer temnplate.
327 # Ensure we fail the job if any steps fail.
330 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
331 PACKER_BUILD_LOG="$PACKER_LOGS_DIR/packer-build.log"
332 mkdir -p "$PACKER_LOGS_DIR"
333 export PATH="${WORKSPACE}/bin:$PATH"
336 export PACKER_LOG="yes" && \
337 export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \
338 packer.io build -color=false \
339 -var-file="$CLOUDENV" \
340 -var-file="../packer/vars/$PACKER_PLATFORM.json" \
341 "../packer/templates/$PACKER_TEMPLATE.json"
343 # Retrive the list of cloud providers
344 clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json"))
346 # Split public/private clouds logs
347 for cloud in "${clouds[@]}"; do
348 grep -e "$cloud" "$PACKER_BUILD_LOG" > "$PACKER_LOGS_DIR/packer-build_$cloud.log" 2>&1
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 "---> packer-clear-credentials.sh"
365 set +e # DO NOT cause build failure if any of the rm calls fail.
366 rm "$CLOUDENV"
369 </hudson.tasks.Shell>
372 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
376 # SPDX-License-Identifier: EPL-1.0
377 ##############################################################################
378 # Copyright (c) 2017 The Linux Foundation and others.
380 # All rights reserved. This program and the accompanying materials
381 # are made available under the terms of the Eclipse Public License v1.0
382 # which accompanies this distribution, and is available at
383 # http://www.eclipse.org/legal/epl-v10.html
384 ##############################################################################
385 echo "---> sysstat.sh"
386 set +e # DON'T fail build if script fails.
388 OS=$(facter operatingsystem)
389 case "$OS" in
391 SYSSTAT_PATH="/var/log/sysstat"
393 # Dont run the script when systat is not enabled by default
394 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
399 SYSSTAT_PATH="/var/log/sa"
407 SAR_DIR="$WORKSPACE/archives/sar-reports"
408 mkdir -p "$SAR_DIR"
409 cp "$SYSSTAT_PATH/"* "$_"
410 # convert sar data to ascii format
411 while IFS="" read -r s
413 [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
414 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
416 # DON'T fail build if script fails.
419 </hudson.tasks.Shell>
420 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
422 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
423 <fileId>jenkins-log-archives-settings</fileId>
425 <variable>SETTINGS_FILE</variable>
426 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
428 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
431 <propertiesContent>SERVER_ID=logs</propertiesContent>
436 # SPDX-License-Identifier: EPL-1.0
437 ##############################################################################
438 # Copyright (c) 2017 The Linux Foundation and others.
440 # All rights reserved. This program and the accompanying materials
441 # are made available under the terms of the Eclipse Public License v1.0
442 # which accompanies this distribution, and is available at
443 # http://www.eclipse.org/legal/epl-v10.html
444 ##############################################################################
445 echo "---> create-netrc.sh"
447 # Ensure we fail the job if any steps fail.
450 NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
451 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
452 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
453 -v x:username -o ":" -v x:password \
454 "$SETTINGS_FILE")
456 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
457 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
458 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
460 echo "machine $machine login $user password $pass" > ~/.netrc
462 </hudson.tasks.Shell>
465 # SPDX-License-Identifier: EPL-1.0
466 ##############################################################################
467 # Copyright (c) 2017 The Linux Foundation and others.
469 # All rights reserved. This program and the accompanying materials
470 # are made available under the terms of the Eclipse Public License v1.0
471 # which accompanies this distribution, and is available at
472 # http://www.eclipse.org/legal/epl-v10.html
473 ##############################################################################
474 echo "---> lftools-install.sh"
476 # Ensure we fail the job if any steps fail.
477 # DO NOT set -u as virtualenv's activate script has unbound variables
480 virtualenv --quiet "/tmp/v/lftools"
481 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
482 source "/tmp/v/lftools/bin/activate"
483 pip install --quiet --upgrade pip
484 pip install --quiet --upgrade "lftools<1.0.0"
486 # pipdeptree prints out a lot of information because lftools pulls in many
487 # dependencies. Let's only print it if we want to debug.
488 # echo "----> Pip Dependency Tree"
489 # pip install --quiet --upgrade pipdeptree
493 # SPDX-License-Identifier: EPL-1.0
494 ##############################################################################
495 # Copyright (c) 2017 The Linux Foundation and others.
497 # All rights reserved. This program and the accompanying materials
498 # are made available under the terms of the Eclipse Public License v1.0
499 # which accompanies this distribution, and is available at
500 # http://www.eclipse.org/legal/epl-v10.html
501 ##############################################################################
502 echo "---> logs-deploy.sh"
504 # Ensure we fail the job if any steps fail.
507 set -x # Trace commands for this script to make debugging easier.
509 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
510 LOGS_SERVER="${LOGS_SERVER:-None}"
512 if [ "${LOGS_SERVER}" == 'None' ]
514 set +x # Disable trace since we no longer need it
516 echo "WARNING: Logging server not set"
518 NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
519 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
520 BUILD_URL="${BUILD_URL}"
522 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
523 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
525 set +x # Disable trace since we no longer need it.
527 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
530 </hudson.tasks.Shell>
533 # SPDX-License-Identifier: EPL-1.0
534 ##############################################################################
535 # Copyright (c) 2017 The Linux Foundation and others.
537 # All rights reserved. This program and the accompanying materials
538 # are made available under the terms of the Eclipse Public License v1.0
539 # which accompanies this distribution, and is available at
540 # http://www.eclipse.org/legal/epl-v10.html
541 ##############################################################################
543 # Clear log credential files
544 rm "$SETTINGS_FILE"
547 </hudson.tasks.Shell>
548 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
549 <regexp>^Build logs: .*</regexp>
550 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
552 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
553 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
554 <markBuildUnstable>false</markBuildUnstable>
555 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
556 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
558 <hudson.plugins.ws__cleanup.Pattern>
559 <pattern>**/*.jenkins-trigger</pattern>
561 </hudson.plugins.ws__cleanup.Pattern>
563 <deleteDirs>false</deleteDirs>
564 <cleanupMatrixParent>false</cleanupMatrixParent>
566 <cleanWhenSuccess>true</cleanWhenSuccess>
567 <cleanWhenUnstable>true</cleanWhenUnstable>
568 <cleanWhenFailure>true</cleanWhenFailure>
569 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
570 <cleanWhenAborted>true</cleanWhenAborted>
571 <notFailBuild>true</notFailBuild>
572 </hudson.plugins.ws__cleanup.WsCleanup>
575 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
576 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
577 <timeoutMinutes>45</timeoutMinutes>
578 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
579 <failBuild>true</failBuild>
580 <writingDescription>false</writingDescription>
581 <timeoutPercentage>0</timeoutPercentage>
582 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
583 <timeoutType>absolute</timeoutType>
584 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
585 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
586 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
587 <user>test-credential</user>
588 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
589 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>