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.
65 <defaultValue>refs/heads/master</defaultValue>
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.1.3</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>
99 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
100 <remotePoll>false</remotePoll>
101 <gitTool>Default</gitTool>
102 <submoduleCfg class="list"/>
107 <hudson.plugins.git.extensions.impl.BuildChooserSetting>
108 <buildChooser class="com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser"/>
109 </hudson.plugins.git.extensions.impl.BuildChooserSetting>
110 <hudson.plugins.git.extensions.impl.SubmoduleOption>
111 <disableSubmodules>false</disableSubmodules>
112 <recursiveSubmodules>true</recursiveSubmodules>
113 <trackingSubmodules>false</trackingSubmodules>
114 <parentCredentials>false</parentCredentials>
116 <timeout>10</timeout>
117 </hudson.plugins.git.extensions.impl.SubmoduleOption>
118 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
121 <triggers class="vector">
122 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
125 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
126 <compareType>ANT</compareType>
127 <pattern>releng/ciman</pattern>
129 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
130 <compareType>ANT</compareType>
131 <pattern>**/master</pattern>
132 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
135 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
136 <compareType>ANT</compareType>
137 <pattern>packer/vars/**.json</pattern>
138 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
139 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
140 <compareType>ANT</compareType>
141 <pattern>packer/templates/**.json</pattern>
142 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
143 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
144 <compareType>ANT</compareType>
145 <pattern>packer/provision/**.sh</pattern>
146 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
147 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
148 <compareType>ANT</compareType>
149 <pattern>packer/provision/lib/**</pattern>
150 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
152 <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
153 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
156 <onSuccessful>false</onSuccessful>
157 <onFailed>false</onFailed>
158 <onUnstable>false</onUnstable>
159 <onNotBuilt>false</onNotBuilt>
161 <silentMode>false</silentMode>
162 <silentStartMode>false</silentStartMode>
163 <escapeQuotes>true</escapeQuotes>
164 <noNameAndEmailParameters>false</noNameAndEmailParameters>
165 <readableMessage>false</readableMessage>
166 <dependencyJobsNames/>
168 <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
170 <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
172 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
173 <excludeDrafts>true</excludeDrafts>
174 <excludeTrivialRebase>false</excludeTrivialRebase>
175 <excludeNoCodeChange>false</excludeNoCodeChange>
176 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
177 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginDraftPublishedEvent/>
178 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
179 <commentAddedCommentContains>recheck$</commentAddedCommentContains>
180 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
183 <buildFailureMessage/>
184 <buildSuccessfulMessage/>
185 <buildUnstableMessage/>
186 <buildNotBuiltMessage/>
187 <buildUnsuccessfulFilepath/>
189 <serverName>test-server</serverName>
190 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
193 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
195 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
196 <fileId>ci-packer-cloud-env</fileId>
198 <variable>CLOUDENV</variable>
199 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
201 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
204 <propertiesContent>PACKER_VERSION=1.1.3
210 # SPDX-License-Identifier: EPL-1.0
211 ##############################################################################
212 # Copyright (c) 2017 The Linux Foundation and others.
214 # All rights reserved. This program and the accompanying materials
215 # are made available under the terms of the Eclipse Public License v1.0
216 # which accompanies this distribution, and is available at
217 # http://www.eclipse.org/legal/epl-v10.html
218 ##############################################################################
219 echo "---> packer-install.sh"
220 # The script checks for the packer binaries and installs the binary
221 # if its not available
223 # $PACKER_VERSION : Define a packer version passed as job paramter
225 PACKER_VERSION="${PACKER_VERSION:-1.1.3}"
227 # Ensure we fail the job if any steps fail.
230 if hash packer.io 2>/dev/null; then
231 echo "packer.io command is available."
233 echo "packer.io command not is available. Installing packer ..."
234 # Installs Hashicorp's Packer binary, required for verify & merge packer jobs
235 pushd "${WORKSPACE}"
236 wget -nv "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
237 mkdir -p "${WORKSPACE}/bin"
238 unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d "${WORKSPACE}/bin/"
239 # rename packer to avoid conflict with binary in cracklib
240 mv "${WORKSPACE}/bin/packer" "${WORKSPACE}/bin/packer.io"
245 # SPDX-License-Identifier: EPL-1.0
246 ##############################################################################
247 # Copyright (c) 2017 The Linux Foundation and others.
249 # All rights reserved. This program and the accompanying materials
250 # are made available under the terms of the Eclipse Public License v1.0
251 # which accompanies this distribution, and is available at
252 # http://www.eclipse.org/legal/epl-v10.html
253 ##############################################################################
254 echo "---> packer-validate.sh"
255 # The script validates an packers files.
257 # $CLOUDENV : Provides the cloud credential file.
259 # Ensure we fail the job if any steps fail.
262 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
263 mkdir -p "$PACKER_LOGS_DIR"
264 export PATH="${WORKSPACE}/bin:$PATH"
267 varfiles=(vars/*.json common-packer/vars/*.json)
268 templates=(templates/*.json)
270 for varfile in "${varfiles[@]}"; do
271 # cloud-env.json is a file containing credentials which is pulled in via
272 # CLOUDENV variable so skip it here. Also handle the case where a project
273 # has not vars/*.json file.
274 if [[ "$varfile" == *"cloud-env.json"* ]] || [[ "$varfile" == 'vars/*.json' ]]; then
278 echo "-----> Testing varfile: $varfile"
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 if output=$(packer.io validate -var-file="$CLOUDENV" -var-file="$varfile" "$template"); then
283 echo "$template: $output"
285 echo "$template: $output"
291 </hudson.tasks.Shell>
294 # SPDX-License-Identifier: EPL-1.0
295 ##############################################################################
296 # Copyright (c) 2017 The Linux Foundation and others.
298 # All rights reserved. This program and the accompanying materials
299 # are made available under the terms of the Eclipse Public License v1.0
300 # which accompanies this distribution, and is available at
301 # http://www.eclipse.org/legal/epl-v10.html
302 ##############################################################################
303 echo "---> packer-clear-credentials.sh"
305 set +e # DO NOT cause build failure if any of the rm calls fail.
306 rm "$CLOUDENV"
309 </hudson.tasks.Shell>
312 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
316 # SPDX-License-Identifier: EPL-1.0
317 ##############################################################################
318 # Copyright (c) 2017 The Linux Foundation and others.
320 # All rights reserved. This program and the accompanying materials
321 # are made available under the terms of the Eclipse Public License v1.0
322 # which accompanies this distribution, and is available at
323 # http://www.eclipse.org/legal/epl-v10.html
324 ##############################################################################
325 echo "---> sysstat.sh"
326 set +e # DON'T fail build if script fails.
328 OS=$(facter operatingsystem)
329 case "$OS" in
331 SYSSTAT_PATH="/var/log/sysstat"
333 # Dont run the script when systat is not enabled by default
334 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
339 SYSSTAT_PATH="/var/log/sa"
347 SAR_DIR="$WORKSPACE/archives/sar-reports"
348 mkdir -p "$SAR_DIR"
349 cp "$SYSSTAT_PATH/"* "$_"
350 # convert sar data to ascii format
351 while IFS="" read -r sarfilenum
353 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
354 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
356 # DON'T fail build if script fails.
359 </hudson.tasks.Shell>
360 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
362 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
363 <fileId>jenkins-log-archives-settings</fileId>
365 <variable>SETTINGS_FILE</variable>
366 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
368 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
371 <propertiesContent>SERVER_ID=logs</propertiesContent>
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 "---> create-netrc.sh"
387 # Ensure we fail the job if any steps fail.
390 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
391 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
392 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
393 -v x:username -o ":" -v x:password \
394 "$SETTINGS_FILE")
396 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
397 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
398 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
400 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
402 </hudson.tasks.Shell>
405 # SPDX-License-Identifier: EPL-1.0
406 ##############################################################################
407 # Copyright (c) 2017 The Linux Foundation and others.
409 # All rights reserved. This program and the accompanying materials
410 # are made available under the terms of the Eclipse Public License v1.0
411 # which accompanies this distribution, and is available at
412 # http://www.eclipse.org/legal/epl-v10.html
413 ##############################################################################
414 echo "---> lftools-install.sh"
416 # Script to install lftools via a version passed in via lf-infra-parameters
418 # Required parameters:
420 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
421 # set to a strict version number like '1.2.3' or using
422 # PEP-440 definitions.
426 # >=1.0.0,<2.0.0
428 # By default a released version of lftools should always be used.
429 # The purpose of the 2 variables below is so that lftools devs can test
430 # unreleased versions of lftools. There are 2 methods to install a dev version
433 # 1) gerrit patch: Used to test a patch that has not yet been merged.
434 # To do this set something like this:
435 # LFTOOLS_MODE=gerrit
436 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
438 # 2) git branch: Used to install an lftools version from a specific branch.
439 # To use this set the variables as follows:
441 # LFTOOLS_REFSPEC=master
443 # 3) release : The intended use case and default setting.
444 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
446 LFTOOLS_MODE=release # release | git | gerrit
447 LFTOOLS_REFSPEC=master
449 # Ensure we fail the job if any steps fail.
450 # DO NOT set -u as virtualenv's activate script has unbound variables
453 virtualenv --quiet "/tmp/v/lftools"
454 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
455 source "/tmp/v/lftools/bin/activate"
456 pip install --quiet --upgrade pip
458 case $LFTOOLS_MODE in
460 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
462 git fetch origin "$LFTOOLS_REFSPEC"
463 git checkout FETCH_HEAD
464 pip install --quiet --upgrade -r requirements.txt
465 pip install --quiet --upgrade -e .
470 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
474 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
475 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
478 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
484 # pipdeptree prints out a lot of information because lftools pulls in many
485 # dependencies. Let's only print it if we want to debug.
486 # echo "----> Pip Dependency Tree"
487 # pip install --quiet --upgrade pipdeptree
491 # SPDX-License-Identifier: EPL-1.0
492 ##############################################################################
493 # Copyright (c) 2017 The Linux Foundation and others.
495 # All rights reserved. This program and the accompanying materials
496 # are made available under the terms of the Eclipse Public License v1.0
497 # which accompanies this distribution, and is available at
498 # http://www.eclipse.org/legal/epl-v10.html
499 ##############################################################################
500 echo "---> logs-deploy.sh"
502 # Ensure we fail the job if any steps fail.
505 set -x # Trace commands for this script to make debugging easier.
507 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
508 LOGS_SERVER="${LOGS_SERVER:-None}"
510 if [ "${LOGS_SERVER}" == 'None' ]
512 set +x # Disable trace since we no longer need it
514 echo "WARNING: Logging server not set"
516 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
517 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
518 BUILD_URL="${BUILD_URL}"
520 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
521 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
523 set +x # Disable trace since we no longer need it.
525 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
528 </hudson.tasks.Shell>
531 # SPDX-License-Identifier: EPL-1.0
532 ##############################################################################
533 # Copyright (c) 2017 The Linux Foundation and others.
535 # All rights reserved. This program and the accompanying materials
536 # are made available under the terms of the Eclipse Public License v1.0
537 # which accompanies this distribution, and is available at
538 # http://www.eclipse.org/legal/epl-v10.html
539 ##############################################################################
541 # Clear log credential files
542 rm "$SETTINGS_FILE"
545 </hudson.tasks.Shell>
546 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
547 <regexp>^Build logs: .*</regexp>
548 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
550 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
551 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
552 <markBuildUnstable>false</markBuildUnstable>
553 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
554 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
556 <hudson.plugins.ws__cleanup.Pattern>
557 <pattern>**/*.jenkins-trigger</pattern>
559 </hudson.plugins.ws__cleanup.Pattern>
561 <deleteDirs>false</deleteDirs>
562 <cleanupMatrixParent>false</cleanupMatrixParent>
564 <cleanWhenSuccess>true</cleanWhenSuccess>
565 <cleanWhenUnstable>true</cleanWhenUnstable>
566 <cleanWhenFailure>true</cleanWhenFailure>
567 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
568 <cleanWhenAborted>true</cleanWhenAborted>
569 <notFailBuild>true</notFailBuild>
570 </hudson.plugins.ws__cleanup.WsCleanup>
573 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
574 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
575 <timeoutMinutes>10</timeoutMinutes>
576 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
577 <failBuild>true</failBuild>
578 <writingDescription>false</writingDescription>
579 <timeoutPercentage>0</timeoutPercentage>
580 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
581 <timeoutType>absolute</timeoutType>
582 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
583 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
584 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
585 <user>test-credential</user>
586 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
587 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
588 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
590 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
591 <fileId>npmrc</fileId>
592 <targetLocation>$HOME/.npmrc</targetLocation>
594 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
596 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>