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>false</concurrentBuild>
9 <assignedNode>build-vm</assignedNode>
10 <canRoam>false</canRoam>
12 <jenkins.model.BuildDiscarderProperty>
13 <strategy class="hudson.tasks.LogRotator">
14 <daysToKeep>1</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 </parameterDefinitions>
77 </hudson.model.ParametersDefinitionProperty>
79 <scm class="hudson.plugins.git.GitSCM">
80 <configVersion>2</configVersion>
82 <hudson.plugins.git.UserRemoteConfig>
85 <url>$GIT_URL/$GERRIT_PROJECT</url>
86 <credentialsId>test-credential</credentialsId>
87 </hudson.plugins.git.UserRemoteConfig>
90 <hudson.plugins.git.BranchSpec>
91 <name>refs/heads/master</name>
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>false</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 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
126 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
127 <compareType>ANT</compareType>
128 <pattern>releng/ciman</pattern>
130 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
131 <compareType>ANT</compareType>
132 <pattern>**/master</pattern>
133 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
135 <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
136 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
139 <onSuccessful>false</onSuccessful>
140 <onFailed>false</onFailed>
141 <onUnstable>false</onUnstable>
142 <onNotBuilt>false</onNotBuilt>
144 <silentMode>false</silentMode>
145 <silentStartMode>false</silentStartMode>
146 <escapeQuotes>true</escapeQuotes>
147 <noNameAndEmailParameters>false</noNameAndEmailParameters>
148 <readableMessage>false</readableMessage>
149 <dependencyJobsNames/>
151 <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
153 <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
155 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
156 <commentAddedCommentContains>(un)?lock branch$</commentAddedCommentContains>
157 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
160 <buildFailureMessage/>
161 <buildSuccessfulMessage/>
162 <buildUnstableMessage/>
163 <buildNotBuiltMessage/>
164 <buildUnsuccessfulFilepath/>
166 <serverName>test-server</serverName>
167 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
172 # SPDX-License-Identifier: EPL-1.0
173 ##############################################################################
174 # Copyright (c) 2017 The Linux Foundation and others.
176 # All rights reserved. This program and the accompanying materials
177 # are made available under the terms of the Eclipse Public License v1.0
178 # which accompanies this distribution, and is available at
179 # http://www.eclipse.org/legal/epl-v10.html
180 ##############################################################################
181 # Generates a patch to lock|unlock a branch in Gerrit
183 # Assumes that the project repository was cloned via ssh and thus uses ssh to
184 # install the git commit hook.
186 # Ensure we fail the job if any steps fail.
189 git fetch origin refs/meta/config:config
192 install_gerrit_hook() {
193 ssh_url=$(git remote show origin | grep Fetch | grep 'ssh://' \
194 | awk -F'/' '{print $3}' | awk -F':' '{print $1}')
195 ssh_port=$(git remote show origin | grep Fetch | grep 'ssh://' \
196 | awk -F'/' '{print $3}' | awk -F':' '{print $2}')
198 if [ -z $ssh_url ]; then
199 echo "ERROR: Gerrit SSH URL not found."
203 scp -p -P "$ssh_port" "$ssh_url":hooks/commit-msg .git/hooks/
204 chmod u+x .git/hooks/commit-msg
208 # Groups must be mapped in the groups file before they can be used
209 if ! grep 'Registered Users'; then
210 echo -e "global:Registered-Users\tRegistered Users" >> groups
213 mode=$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep branch | awk '{print $1}')
216 echo "Locking branch: $GERRIT_BRANCH"
217 git config -f project.config "access.refs/heads/${GERRIT_BRANCH}.exclusiveGroupPermissions" "submit"
218 git config -f project.config "access.refs/heads/${GERRIT_BRANCH}.submit" "block group Registered Users"
219 git commit -asm "Lock branch $GERRIT_BRANCH"
223 echo "Unlocking branch: $GERRIT_BRANCH"
224 git config -f project.config --remove-section "access.refs/heads/${GERRIT_BRANCH}" || true
225 git commit -asm "Unlock branch $GERRIT_BRANCH"
229 echo "ERROR: Unknown mode selected '$mode'."
235 git push origin HEAD:refs/for/refs/meta/config
237 </hudson.tasks.Shell>
240 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
244 # SPDX-License-Identifier: EPL-1.0
245 ##############################################################################
246 # Copyright (c) 2017 The Linux Foundation and others.
248 # All rights reserved. This program and the accompanying materials
249 # are made available under the terms of the Eclipse Public License v1.0
250 # which accompanies this distribution, and is available at
251 # http://www.eclipse.org/legal/epl-v10.html
252 ##############################################################################
253 echo "---> sysstat.sh"
254 set +e # DON'T fail build if script fails.
256 OS=$(facter operatingsystem)
257 case "$OS" in
259 SYSSTAT_PATH="/var/log/sysstat"
261 # Dont run the script when systat is not enabled by default
262 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
267 SYSSTAT_PATH="/var/log/sa"
275 SAR_DIR="$WORKSPACE/archives/sar-reports"
276 mkdir -p "$SAR_DIR"
277 cp "$SYSSTAT_PATH/"* "$_"
278 # convert sar data to ascii format
279 while IFS="" read -r s
281 [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
282 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
284 # DON'T fail build if script fails.
287 </hudson.tasks.Shell>
288 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
290 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
291 <fileId>jenkins-log-archives-settings</fileId>
293 <variable>SETTINGS_FILE</variable>
294 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
296 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
299 <propertiesContent>SERVER_ID=logs</propertiesContent>
304 # SPDX-License-Identifier: EPL-1.0
305 ##############################################################################
306 # Copyright (c) 2017 The Linux Foundation and others.
308 # All rights reserved. This program and the accompanying materials
309 # are made available under the terms of the Eclipse Public License v1.0
310 # which accompanies this distribution, and is available at
311 # http://www.eclipse.org/legal/epl-v10.html
312 ##############################################################################
313 echo "---> create-netrc.sh"
315 # Ensure we fail the job if any steps fail.
318 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
319 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
320 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
321 -v x:username -o ":" -v x:password \
322 "$SETTINGS_FILE")
324 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
325 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
326 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
328 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
330 </hudson.tasks.Shell>
333 # SPDX-License-Identifier: EPL-1.0
334 ##############################################################################
335 # Copyright (c) 2017 The Linux Foundation and others.
337 # All rights reserved. This program and the accompanying materials
338 # are made available under the terms of the Eclipse Public License v1.0
339 # which accompanies this distribution, and is available at
340 # http://www.eclipse.org/legal/epl-v10.html
341 ##############################################################################
342 echo "---> lftools-install.sh"
344 # Script to install lftools via a version passed in via lf-infra-parameters
346 # Required parameters:
348 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
349 # set to a strict version number like '1.2.3' or using
350 # PEP-440 definitions.
354 # >=1.0.0,<2.0.0
356 # By default a released version of lftools should always be used.
357 # The purpose of the 2 variables below is so that lftools devs can test
358 # unreleased versions of lftools. There are 2 methods to install a dev version
361 # 1) gerrit patch: Used to test a patch that has not yet been merged.
362 # To do this set something like this:
363 # LFTOOLS_MODE=gerrit
364 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
366 # 2) git branch: Used to install an lftools version from a specific branch.
367 # To use this set the variables as follows:
369 # LFTOOLS_REFSPEC=master
371 # 3) release : The intended use case and default setting.
372 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
374 LFTOOLS_MODE=release # release | git | gerrit
375 LFTOOLS_REFSPEC=master
377 # Ensure we fail the job if any steps fail.
378 # DO NOT set -u as virtualenv's activate script has unbound variables
381 virtualenv --quiet "/tmp/v/lftools"
382 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
383 source "/tmp/v/lftools/bin/activate"
384 pip install --quiet --upgrade pip
386 case $LFTOOLS_MODE in
388 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
390 git fetch origin "$LFTOOLS_REFSPEC"
391 git checkout FETCH_HEAD
392 pip install --quiet --upgrade -r requirements.txt
393 pip install --quiet --upgrade -e .
398 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
402 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
403 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
406 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
412 # pipdeptree prints out a lot of information because lftools pulls in many
413 # dependencies. Let's only print it if we want to debug.
414 # echo "----> Pip Dependency Tree"
415 # pip install --quiet --upgrade pipdeptree
419 # SPDX-License-Identifier: EPL-1.0
420 ##############################################################################
421 # Copyright (c) 2017 The Linux Foundation and others.
423 # All rights reserved. This program and the accompanying materials
424 # are made available under the terms of the Eclipse Public License v1.0
425 # which accompanies this distribution, and is available at
426 # http://www.eclipse.org/legal/epl-v10.html
427 ##############################################################################
428 echo "---> logs-deploy.sh"
430 # Ensure we fail the job if any steps fail.
433 set -x # Trace commands for this script to make debugging easier.
435 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
436 LOGS_SERVER="${LOGS_SERVER:-None}"
438 if [ "${LOGS_SERVER}" == 'None' ]
440 set +x # Disable trace since we no longer need it
442 echo "WARNING: Logging server not set"
444 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
445 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
446 BUILD_URL="${BUILD_URL}"
448 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
449 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
451 set +x # Disable trace since we no longer need it.
453 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
456 </hudson.tasks.Shell>
459 # SPDX-License-Identifier: EPL-1.0
460 ##############################################################################
461 # Copyright (c) 2017 The Linux Foundation and others.
463 # All rights reserved. This program and the accompanying materials
464 # are made available under the terms of the Eclipse Public License v1.0
465 # which accompanies this distribution, and is available at
466 # http://www.eclipse.org/legal/epl-v10.html
467 ##############################################################################
469 # Clear log credential files
470 rm "$SETTINGS_FILE"
473 </hudson.tasks.Shell>
474 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
475 <regexp>^Build logs: .*</regexp>
476 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
478 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
479 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
480 <markBuildUnstable>false</markBuildUnstable>
481 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
482 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
484 <hudson.plugins.ws__cleanup.Pattern>
485 <pattern>**/*.jenkins-trigger</pattern>
487 </hudson.plugins.ws__cleanup.Pattern>
489 <deleteDirs>false</deleteDirs>
490 <cleanupMatrixParent>false</cleanupMatrixParent>
492 <cleanWhenSuccess>true</cleanWhenSuccess>
493 <cleanWhenUnstable>true</cleanWhenUnstable>
494 <cleanWhenFailure>true</cleanWhenFailure>
495 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
496 <cleanWhenAborted>true</cleanWhenAborted>
497 <notFailBuild>true</notFailBuild>
498 </hudson.plugins.ws__cleanup.WsCleanup>
501 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
502 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
503 <timeoutMinutes>5</timeoutMinutes>
504 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
505 <failBuild>true</failBuild>
506 <writingDescription>false</writingDescription>
507 <timeoutPercentage>0</timeoutPercentage>
508 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
509 <timeoutType>absolute</timeoutType>
510 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
511 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
512 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
513 <user>test-credential</user>
514 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
515 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
516 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
518 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
519 <fileId>npmrc</fileId>
520 <targetLocation>$HOME/.npmrc</targetLocation>
522 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
524 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>