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>
94 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
95 <remotePoll>false</remotePoll>
96 <gitTool>Default</gitTool>
97 <submoduleCfg class="list"/>
102 <hudson.plugins.git.extensions.impl.BuildChooserSetting>
103 <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
104 </hudson.plugins.git.extensions.impl.BuildChooserSetting>
105 <hudson.plugins.git.extensions.impl.SubmoduleOption>
106 <disableSubmodules>false</disableSubmodules>
107 <recursiveSubmodules>false</recursiveSubmodules>
108 <trackingSubmodules>false</trackingSubmodules>
109 <parentCredentials>false</parentCredentials>
111 <timeout>10</timeout>
112 </hudson.plugins.git.extensions.impl.SubmoduleOption>
113 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
116 <triggers class="vector">
117 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
120 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
121 <compareType>ANT</compareType>
122 <pattern>releng/ciman</pattern>
124 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
125 <compareType>ANT</compareType>
126 <pattern>**/master</pattern>
127 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
129 <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
130 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
133 <onSuccessful>false</onSuccessful>
134 <onFailed>false</onFailed>
135 <onUnstable>false</onUnstable>
136 <onNotBuilt>false</onNotBuilt>
138 <silentMode>false</silentMode>
139 <silentStartMode>false</silentStartMode>
140 <escapeQuotes>true</escapeQuotes>
141 <noNameAndEmailParameters>false</noNameAndEmailParameters>
142 <readableMessage>false</readableMessage>
143 <dependencyJobsNames/>
145 <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
147 <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
149 <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
150 <commentAddedCommentContains>(un)?lock branch$</commentAddedCommentContains>
151 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
154 <buildFailureMessage/>
155 <buildSuccessfulMessage/>
156 <buildUnstableMessage/>
157 <buildNotBuiltMessage/>
158 <buildUnsuccessfulFilepath/>
160 <serverName>test-server</serverName>
161 </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
166 # SPDX-License-Identifier: EPL-1.0
167 ##############################################################################
168 # Copyright (c) 2017 The Linux Foundation and others.
170 # All rights reserved. This program and the accompanying materials
171 # are made available under the terms of the Eclipse Public License v1.0
172 # which accompanies this distribution, and is available at
173 # http://www.eclipse.org/legal/epl-v10.html
174 ##############################################################################
175 # Generates a patch to lock|unlock a branch in Gerrit
177 # Assumes that the project repository was cloned via ssh and thus uses ssh to
178 # install the git commit hook.
180 # Ensure we fail the job if any steps fail.
183 git fetch origin refs/meta/config:config
186 install_gerrit_hook() {
187 ssh_url=$(git remote show origin | grep Fetch | grep 'ssh://' \
188 | awk -F'/' '{print $3}' | awk -F':' '{print $1}')
189 ssh_port=$(git remote show origin | grep Fetch | grep 'ssh://' \
190 | awk -F'/' '{print $3}' | awk -F':' '{print $2}')
192 if [ -z $ssh_url ]; then
193 echo "ERROR: Gerrit SSH URL not found."
197 scp -p -P "$ssh_port" "$ssh_url":hooks/commit-msg .git/hooks/
198 chmod u+x .git/hooks/commit-msg
202 # Groups must be mapped in the groups file before they can be used
203 if ! grep 'Registered Users'; then
204 echo -e "global:Registered-Users\tRegistered Users" >> groups
207 mode=$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep branch | awk '{print $1}')
210 echo "Locking branch: $GERRIT_BRANCH"
211 git config -f project.config "access.refs/heads/${GERRIT_BRANCH}.exclusiveGroupPermissions" "submit"
212 git config -f project.config "access.refs/heads/${GERRIT_BRANCH}.submit" "block group Registered Users"
213 git commit -asm "Lock branch $GERRIT_BRANCH"
217 echo "Unlocking branch: $GERRIT_BRANCH"
218 git config -f project.config --remove-section "access.refs/heads/${GERRIT_BRANCH}" || true
219 git commit -asm "Unlock branch $GERRIT_BRANCH"
223 echo "ERROR: Unknown mode selected '$mode'."
229 git push origin HEAD:refs/for/refs/meta/config
231 </hudson.tasks.Shell>
234 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
238 # SPDX-License-Identifier: EPL-1.0
239 ##############################################################################
240 # Copyright (c) 2017 The Linux Foundation and others.
242 # All rights reserved. This program and the accompanying materials
243 # are made available under the terms of the Eclipse Public License v1.0
244 # which accompanies this distribution, and is available at
245 # http://www.eclipse.org/legal/epl-v10.html
246 ##############################################################################
247 echo "---> sysstat.sh"
248 set +e # DON'T fail build if script fails.
250 OS=$(facter operatingsystem)
251 case "$OS" in
253 SYSSTAT_PATH="/var/log/sysstat"
255 # Dont run the script when systat is not enabled by default
256 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
261 SYSSTAT_PATH="/var/log/sa"
269 SAR_DIR="$WORKSPACE/archives/sar-reports"
270 mkdir -p "$SAR_DIR"
271 cp "$SYSSTAT_PATH/"* "$_"
272 # convert sar data to ascii format
273 while IFS="" read -r sarfilenum
275 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
276 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
278 # DON'T fail build if script fails.
281 </hudson.tasks.Shell>
282 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
284 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
285 <fileId>jenkins-log-archives-settings</fileId>
287 <variable>SETTINGS_FILE</variable>
288 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
290 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
293 <propertiesContent>SERVER_ID=logs</propertiesContent>
298 # SPDX-License-Identifier: EPL-1.0
299 ##############################################################################
300 # Copyright (c) 2017 The Linux Foundation and others.
302 # All rights reserved. This program and the accompanying materials
303 # are made available under the terms of the Eclipse Public License v1.0
304 # which accompanies this distribution, and is available at
305 # http://www.eclipse.org/legal/epl-v10.html
306 ##############################################################################
307 echo "---> create-netrc.sh"
309 # Ensure we fail the job if any steps fail.
312 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
313 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
314 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
315 -v x:username -o ":" -v x:password \
316 "$SETTINGS_FILE")
318 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
319 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
320 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
322 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
324 </hudson.tasks.Shell>
327 # SPDX-License-Identifier: EPL-1.0
328 ##############################################################################
329 # Copyright (c) 2017 The Linux Foundation and others.
331 # All rights reserved. This program and the accompanying materials
332 # are made available under the terms of the Eclipse Public License v1.0
333 # which accompanies this distribution, and is available at
334 # http://www.eclipse.org/legal/epl-v10.html
335 ##############################################################################
336 echo "---> lftools-install.sh"
338 # Script to install lftools via a version passed in via lf-infra-parameters
340 # Required parameters:
342 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
343 # set to a strict version number like '1.2.3' or using
344 # PEP-440 definitions.
348 # >=1.0.0,<2.0.0
350 # By default a released version of lftools should always be used.
351 # The purpose of the 2 variables below is so that lftools devs can test
352 # unreleased versions of lftools. There are 2 methods to install a dev version
355 # 1) gerrit patch: Used to test a patch that has not yet been merged.
356 # To do this set something like this:
357 # LFTOOLS_MODE=gerrit
358 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
360 # 2) git branch: Used to install an lftools version from a specific branch.
361 # To use this set the variables as follows:
363 # LFTOOLS_REFSPEC=master
365 # 3) release : The intended use case and default setting.
366 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
368 LFTOOLS_MODE=release # release | git | gerrit
369 LFTOOLS_REFSPEC=master
371 # Ensure we fail the job if any steps fail.
372 # DO NOT set -u as virtualenv's activate script has unbound variables
375 virtualenv --quiet "/tmp/v/lftools"
376 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
377 source "/tmp/v/lftools/bin/activate"
378 pip install --quiet --upgrade pip
380 case $LFTOOLS_MODE in
382 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
384 git fetch origin "$LFTOOLS_REFSPEC"
385 git checkout FETCH_HEAD
386 pip install --quiet --upgrade -r requirements.txt
387 pip install --quiet --upgrade -e .
392 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
396 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
397 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
400 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
406 # pipdeptree prints out a lot of information because lftools pulls in many
407 # dependencies. Let's only print it if we want to debug.
408 # echo "----> Pip Dependency Tree"
409 # pip install --quiet --upgrade pipdeptree
413 # SPDX-License-Identifier: EPL-1.0
414 ##############################################################################
415 # Copyright (c) 2017 The Linux Foundation and others.
417 # All rights reserved. This program and the accompanying materials
418 # are made available under the terms of the Eclipse Public License v1.0
419 # which accompanies this distribution, and is available at
420 # http://www.eclipse.org/legal/epl-v10.html
421 ##############################################################################
422 echo "---> logs-deploy.sh"
424 # Ensure we fail the job if any steps fail.
427 set -x # Trace commands for this script to make debugging easier.
429 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
430 LOGS_SERVER="${LOGS_SERVER:-None}"
432 if [ "${LOGS_SERVER}" == 'None' ]
434 set +x # Disable trace since we no longer need it
436 echo "WARNING: Logging server not set"
438 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
439 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
440 BUILD_URL="${BUILD_URL}"
442 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
443 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
445 set +x # Disable trace since we no longer need it.
447 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
450 </hudson.tasks.Shell>
453 # SPDX-License-Identifier: EPL-1.0
454 ##############################################################################
455 # Copyright (c) 2017 The Linux Foundation and others.
457 # All rights reserved. This program and the accompanying materials
458 # are made available under the terms of the Eclipse Public License v1.0
459 # which accompanies this distribution, and is available at
460 # http://www.eclipse.org/legal/epl-v10.html
461 ##############################################################################
463 # Clear log credential files
464 rm "$SETTINGS_FILE"
467 </hudson.tasks.Shell>
468 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
469 <regexp>^Build logs: .*</regexp>
470 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
472 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
473 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
474 <markBuildUnstable>false</markBuildUnstable>
475 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
476 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
478 <hudson.plugins.ws__cleanup.Pattern>
479 <pattern>**/*.jenkins-trigger</pattern>
481 </hudson.plugins.ws__cleanup.Pattern>
483 <deleteDirs>false</deleteDirs>
484 <cleanupMatrixParent>false</cleanupMatrixParent>
486 <cleanWhenSuccess>true</cleanWhenSuccess>
487 <cleanWhenUnstable>true</cleanWhenUnstable>
488 <cleanWhenFailure>true</cleanWhenFailure>
489 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
490 <cleanWhenAborted>true</cleanWhenAborted>
491 <notFailBuild>true</notFailBuild>
492 </hudson.plugins.ws__cleanup.WsCleanup>
495 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
496 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
497 <timeoutMinutes>5</timeoutMinutes>
498 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
499 <failBuild>true</failBuild>
500 <writingDescription>false</writingDescription>
501 <timeoutPercentage>0</timeoutPercentage>
502 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
503 <timeoutType>absolute</timeoutType>
504 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
505 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
506 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
507 <user>test-credential</user>
508 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
509 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
510 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
512 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
513 <fileId>npmrc</fileId>
514 <targetLocation>$HOME/.npmrc</targetLocation>
516 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
518 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>