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 <jenkins.model.BuildDiscarderProperty>
13 <strategy class="hudson.tasks.LogRotator">
14 <daysToKeep>7</daysToKeep>
15 <numToKeep>-1</numToKeep>
16 <artifactDaysToKeep>-1</artifactDaysToKeep>
17 <artifactNumToKeep>0</artifactNumToKeep>
19 </jenkins.model.BuildDiscarderProperty>
20 <hudson.model.ParametersDefinitionProperty>
21 <parameterDefinitions>
22 <hudson.model.StringParameterDefinition>
24 <description>Parameter to identify a Gerrit project. This is typically the
25 project repo path as exists in Gerrit.
26 For example: ofextensions/circuitsw
28 <defaultValue>releng/ciman</defaultValue>
29 </hudson.model.StringParameterDefinition>
30 <hudson.model.StringParameterDefinition>
32 <description>Stream is often set to the same name as 'branch' but can
33 sometimes be used as a name representing a project's release code
36 <defaultValue>master</defaultValue>
37 </hudson.model.StringParameterDefinition>
38 <hudson.model.StringParameterDefinition>
39 <name>GERRIT_PROJECT</name>
40 <description>Parameter to identify Gerrit project. This is typically the
41 project repo path as exists in Gerrit.
42 For example: ofextensions/circuitsw
44 Note that Gerrit will override this parameter automatically if a
45 job is triggered by Gerrit.
47 <defaultValue>releng/ciman</defaultValue>
48 </hudson.model.StringParameterDefinition>
49 <hudson.model.StringParameterDefinition>
50 <name>GERRIT_BRANCH</name>
51 <description>Parameter to identify a Gerrit branch.
53 Note that Gerrit will override this parameter automatically if a
54 job is triggered by Gerrit.
56 <defaultValue>master</defaultValue>
57 </hudson.model.StringParameterDefinition>
58 <hudson.model.StringParameterDefinition>
59 <name>GERRIT_REFSPEC</name>
60 <description>Parameter to identify a refspec when pulling from Gerrit.
62 Note that Gerrit will override this parameter automatically if a
63 job is triggered by Gerrit.
66 </hudson.model.StringParameterDefinition>
67 <hudson.model.StringParameterDefinition>
68 <name>LFTOOLS_VERSION</name>
69 <description>Version of lftools to install. Can be a specific version like
70 '0.6.0' or a PEP-440 definition.
71 https://www.python.org/dev/peps/pep-0440/
72 For example '<1.0.0' or '>=1.0.0,<2.0.0'.
74 <defaultValue><1.0.0</defaultValue>
75 </hudson.model.StringParameterDefinition>
76 <hudson.model.StringParameterDefinition>
77 <name>PACKER_VERSION</name>
78 <description>Packer version to download and install.</description>
79 <defaultValue>1.0.2</defaultValue>
80 </hudson.model.StringParameterDefinition>
81 </parameterDefinitions>
82 </hudson.model.ParametersDefinitionProperty>
84 <scm class="hudson.plugins.git.GitSCM">
85 <configVersion>2</configVersion>
87 <hudson.plugins.git.UserRemoteConfig>
89 <refspec>$GERRIT_REFSPEC</refspec>
90 <url>$GIT_URL/$GERRIT_PROJECT</url>
91 <credentialsId>test-credential</credentialsId>
92 </hudson.plugins.git.UserRemoteConfig>
95 <hudson.plugins.git.BranchSpec>
96 <name>refs/heads/$GERRIT_BRANCH</name>
97 </hudson.plugins.git.BranchSpec>
100 <buildChooser class="com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser"/>
101 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
102 <authorOrCommitter>false</authorOrCommitter>
103 <wipeOutWorkspace>true</wipeOutWorkspace>
104 <pruneBranches>false</pruneBranches>
105 <remotePoll>false</remotePoll>
106 <gitTool>Default</gitTool>
107 <submoduleCfg class="list"/>
112 <skipTag>true</skipTag>
114 <useShallowClone>false</useShallowClone>
115 <ignoreNotifyCommit>false</ignoreNotifyCommit>
117 <hudson.plugins.git.extensions.impl.SubmoduleOption>
118 <disableSubmodules>false</disableSubmodules>
119 <recursiveSubmodules>true</recursiveSubmodules>
120 <trackingSubmodules>false</trackingSubmodules>
122 <timeout>10</timeout>
123 </hudson.plugins.git.extensions.impl.SubmoduleOption>
124 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
127 <triggers class="vector">
128 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
131 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
132 <compareType>ANT</compareType>
133 <pattern>releng/ciman</pattern>
135 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
136 <compareType>ANT</compareType>
137 <pattern>**/master</pattern>
138 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
141 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
142 <compareType>ANT</compareType>
143 <pattern>packer/vars/['centos', 'ubuntu1604'].json</pattern>
144 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
145 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
146 <compareType>ANT</compareType>
147 <pattern>packer/templates/['java-builder', 'mininet'].json</pattern>
148 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
149 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
150 <compareType>ANT</compareType>
151 <pattern>packer/provision/['java-builder', 'mininet'].sh</pattern>
152 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
153 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
154 <compareType>ANT</compareType>
155 <pattern>packer/provision/lib/**</pattern>
156 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
158 <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
159 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
162 <onSuccessful>false</onSuccessful>
163 <onFailed>false</onFailed>
164 <onUnstable>false</onUnstable>
165 <onNotBuilt>false</onNotBuilt>
167 <silentMode>false</silentMode>
168 <silentStartMode>false</silentStartMode>
169 <escapeQuotes>true</escapeQuotes>
170 <noNameAndEmailParameters>false</noNameAndEmailParameters>
171 <readableMessage>false</readableMessage>
172 <dependencyJobsNames/>
174 <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
176 <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
178 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
179 <excludeDrafts>false</excludeDrafts>
180 <excludeTrivialRebase>false</excludeTrivialRebase>
181 <excludeNoCodeChange>false</excludeNoCodeChange>
182 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
183 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginDraftPublishedEvent/>
184 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
185 <commentAddedCommentContains>recheck$</commentAddedCommentContains>
186 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
189 <buildFailureMessage/>
190 <buildSuccessfulMessage/>
191 <buildUnstableMessage/>
192 <buildNotBuiltMessage/>
193 <buildUnsuccessfulFilepath/>
195 <serverName>test-server</serverName>
196 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
199 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
201 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
202 <fileId>ci-packer-cloud-env</fileId>
204 <variable>CLOUDENV</variable>
205 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
207 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
210 <propertiesContent>PACKER_VERSION=1.0.2
216 # SPDX-License-Identifier: EPL-1.0
217 ##############################################################################
218 # Copyright (c) 2017 The Linux Foundation and others.
220 # All rights reserved. This program and the accompanying materials
221 # are made available under the terms of the Eclipse Public License v1.0
222 # which accompanies this distribution, and is available at
223 # http://www.eclipse.org/legal/epl-v10.html
224 ##############################################################################
225 echo "---> packer-install.sh"
226 # The script checks for the packer binaries and installs the binary
227 # if its not available
229 # $PACKER_VERSION : Define a packer version passed as job paramter
231 PACKER_VERSION="${PACKER_VERSION:-1.0.2}"
233 # Ensure we fail the job if any steps fail.
235 # Default packer binary made available on the build image
236 packer_bin="/usr/local/bin/packer.io"
238 if hash "$packer_bin" 2>/dev/null; then
239 echo "packer.io command is available."
241 echo "packer.io command not is available. Installing packer ..."
242 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
244 wget "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
245 mkdir -p "${WORKSPACE}/bin"
246 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
247 # rename packer to avoid conflict with binary in cracklib
248 mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
253 # SPDX-License-Identifier: EPL-1.0
254 ##############################################################################
255 # Copyright (c) 2017 The Linux Foundation and others.
257 # All rights reserved. This program and the accompanying materials
258 # are made available under the terms of the Eclipse Public License v1.0
259 # which accompanies this distribution, and is available at
260 # http://www.eclipse.org/legal/epl-v10.html
261 ##############################################################################
262 echo "---> packer-validate.sh"
263 # The script validates an packers files.
265 # $CLOUDENV : Provides the cloud credential file.
267 # Ensure we fail the job if any steps fail.
270 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
271 mkdir -p "$PACKER_LOGS_DIR"
272 export PATH="${WORKSPACE}/bin:$PATH"
275 varfiles=(../packer/vars/*.json)
276 templates=(../packer/templates/*.json)
278 for varfile in "${varfiles[@]}"; do
279 for template in "${templates[@]}"; do
280 export PACKER_LOG="yes" && \
281 export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log" && \
282 packer.io validate -var-file="$CLOUDENV" \
283 -var-file="$varfile" "$template"
284 if [ $? -ne 0 ]; then
290 </hudson.tasks.Shell>
293 # SPDX-License-Identifier: EPL-1.0
294 ##############################################################################
295 # Copyright (c) 2017 The Linux Foundation and others.
297 # All rights reserved. This program and the accompanying materials
298 # are made available under the terms of the Eclipse Public License v1.0
299 # which accompanies this distribution, and is available at
300 # http://www.eclipse.org/legal/epl-v10.html
301 ##############################################################################
302 echo "---> packer-clear-credentials.sh"
304 set +e # DO NOT cause build failure if any of the rm calls fail.
305 rm "$CLOUDENV"
308 </hudson.tasks.Shell>
311 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
315 # SPDX-License-Identifier: EPL-1.0
316 ##############################################################################
317 # Copyright (c) 2017 The Linux Foundation and others.
319 # All rights reserved. This program and the accompanying materials
320 # are made available under the terms of the Eclipse Public License v1.0
321 # which accompanies this distribution, and is available at
322 # http://www.eclipse.org/legal/epl-v10.html
323 ##############################################################################
324 echo "---> sysstat.sh"
325 set +e # DON'T fail build if script fails.
327 OS=$(facter operatingsystem)
328 case "$OS" in
330 SYSSTAT_PATH="/var/log/sysstat"
332 # Dont run the script when systat is not enabled by default
333 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
338 SYSSTAT_PATH="/var/log/sa"
346 SAR_DIR="$WORKSPACE/archives/sar-reports"
347 mkdir -p "$SAR_DIR"
348 cp "$SYSSTAT_PATH/"* "$_"
349 # convert sar data to ascii format
350 while IFS="" read -r s
352 [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
353 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
355 # DON'T fail build if script fails.
358 </hudson.tasks.Shell>
359 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
361 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
362 <fileId>jenkins-log-archives-settings</fileId>
364 <variable>SETTINGS_FILE</variable>
365 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
367 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
370 <propertiesContent>SERVER_ID=logs</propertiesContent>
375 # SPDX-License-Identifier: EPL-1.0
376 ##############################################################################
377 # Copyright (c) 2017 The Linux Foundation and others.
379 # All rights reserved. This program and the accompanying materials
380 # are made available under the terms of the Eclipse Public License v1.0
381 # which accompanies this distribution, and is available at
382 # http://www.eclipse.org/legal/epl-v10.html
383 ##############################################################################
384 echo "---> create-netrc.sh"
386 # Ensure we fail the job if any steps fail.
389 NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
390 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
391 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
392 -v x:username -o ":" -v x:password \
393 "$SETTINGS_FILE")
395 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
396 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
397 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
399 echo "machine $machine login $user password $pass" > ~/.netrc
401 </hudson.tasks.Shell>
404 # SPDX-License-Identifier: EPL-1.0
405 ##############################################################################
406 # Copyright (c) 2017 The Linux Foundation and others.
408 # All rights reserved. This program and the accompanying materials
409 # are made available under the terms of the Eclipse Public License v1.0
410 # which accompanies this distribution, and is available at
411 # http://www.eclipse.org/legal/epl-v10.html
412 ##############################################################################
413 echo "---> lftools-install.sh"
415 # Script to install lftools via a version passed in via lf-infra-parameters
417 # Required parameters:
419 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
420 # set to a strict version number like '1.2.3' or using
421 # PEP-440 definitions.
425 # >=1.0.0,<2.0.0
427 # By default a released version of lftools should always be used.
428 # The purpose of the 2 variables below is so that lftools devs can test
429 # unreleased versions of lftools. There are 2 methods to install a dev version
432 # 1) gerrit patch: Used to test a patch that has not yet been merged.
433 # To do this set something like this:
434 # LFTOOLS_MODE=gerrit
435 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
437 # 2) git branch: Used to install an lftools version from a specific branch.
438 # To use this set the variables as follows:
440 # LFTOOLS_REFSPEC=master
442 # 3) release : The intended use case and default setting.
443 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
445 LFTOOLS_MODE=release # release | git | gerrit
446 LFTOOLS_REFSPEC=master
448 # Ensure we fail the job if any steps fail.
449 # DO NOT set -u as virtualenv's activate script has unbound variables
452 virtualenv --quiet "/tmp/v/lftools"
453 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
454 source "/tmp/v/lftools/bin/activate"
455 pip install --quiet --upgrade pip
457 case $LFTOOLS_MODE in
459 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
461 git fetch origin "$LFTOOLS_REFSPEC"
462 git checkout FETCH_HEAD
463 pip install --quiet --upgrade -r requirements.txt
464 pip install --quiet --upgrade -e .
469 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
473 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
474 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
477 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
483 # pipdeptree prints out a lot of information because lftools pulls in many
484 # dependencies. Let's only print it if we want to debug.
485 # echo "----> Pip Dependency Tree"
486 # pip install --quiet --upgrade pipdeptree
490 # SPDX-License-Identifier: EPL-1.0
491 ##############################################################################
492 # Copyright (c) 2017 The Linux Foundation and others.
494 # All rights reserved. This program and the accompanying materials
495 # are made available under the terms of the Eclipse Public License v1.0
496 # which accompanies this distribution, and is available at
497 # http://www.eclipse.org/legal/epl-v10.html
498 ##############################################################################
499 echo "---> logs-deploy.sh"
501 # Ensure we fail the job if any steps fail.
504 set -x # Trace commands for this script to make debugging easier.
506 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
507 LOGS_SERVER="${LOGS_SERVER:-None}"
509 if [ "${LOGS_SERVER}" == 'None' ]
511 set +x # Disable trace since we no longer need it
513 echo "WARNING: Logging server not set"
515 NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
516 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
517 BUILD_URL="${BUILD_URL}"
519 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
520 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
522 set +x # Disable trace since we no longer need it.
524 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
527 </hudson.tasks.Shell>
530 # SPDX-License-Identifier: EPL-1.0
531 ##############################################################################
532 # Copyright (c) 2017 The Linux Foundation and others.
534 # All rights reserved. This program and the accompanying materials
535 # are made available under the terms of the Eclipse Public License v1.0
536 # which accompanies this distribution, and is available at
537 # http://www.eclipse.org/legal/epl-v10.html
538 ##############################################################################
540 # Clear log credential files
541 rm "$SETTINGS_FILE"
544 </hudson.tasks.Shell>
545 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
546 <regexp>^Build logs: .*</regexp>
547 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
549 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
550 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
551 <markBuildUnstable>false</markBuildUnstable>
552 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
553 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
555 <hudson.plugins.ws__cleanup.Pattern>
556 <pattern>**/*.jenkins-trigger</pattern>
558 </hudson.plugins.ws__cleanup.Pattern>
560 <deleteDirs>false</deleteDirs>
561 <cleanupMatrixParent>false</cleanupMatrixParent>
563 <cleanWhenSuccess>true</cleanWhenSuccess>
564 <cleanWhenUnstable>true</cleanWhenUnstable>
565 <cleanWhenFailure>true</cleanWhenFailure>
566 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
567 <cleanWhenAborted>true</cleanWhenAborted>
568 <notFailBuild>true</notFailBuild>
569 </hudson.plugins.ws__cleanup.WsCleanup>
572 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
573 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
574 <timeoutMinutes>10</timeoutMinutes>
575 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
576 <failBuild>true</failBuild>
577 <writingDescription>false</writingDescription>
578 <timeoutPercentage>0</timeoutPercentage>
579 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
580 <timeoutType>absolute</timeoutType>
581 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
582 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
583 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
584 <user>test-credential</user>
585 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
586 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>