1 <?xml version="1.0" encoding="utf-8"?>
5 <description><!-- Managed by Jenkins Job Builder --></description>
6 <keepDependencies>false</keepDependencies>
7 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
8 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
9 <concurrentBuild>false</concurrentBuild>
10 <assignedNode>build-vm</assignedNode>
11 <canRoam>false</canRoam>
13 <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github">
14 <projectUrl>$GIT_URL/$PROJECT/example-org/releng/ciman</projectUrl>
16 </com.coravy.hudson.plugins.github.GithubProjectProperty>
17 <hudson.model.ParametersDefinitionProperty>
18 <parameterDefinitions>
19 <hudson.model.StringParameterDefinition>
21 <description>Parameter to identify a Gerrit project. This is typically the
22 project repo path as exists in Gerrit.
23 For example: ofextensions/circuitsw
25 <defaultValue>releng/ciman</defaultValue>
26 </hudson.model.StringParameterDefinition>
27 <hudson.model.StringParameterDefinition>
29 <description>Stream is often set to the same name as 'branch' but can
30 sometimes be used as a name representing a project's release code
33 <defaultValue>master</defaultValue>
34 </hudson.model.StringParameterDefinition>
35 <hudson.model.StringParameterDefinition>
36 <name>GERRIT_PROJECT</name>
37 <description>Parameter to identify Gerrit project. This is typically the
38 project repo path as exists in Gerrit.
39 For example: ofextensions/circuitsw
41 Note that Gerrit will override this parameter automatically if a
42 job is triggered by Gerrit.
44 <defaultValue>releng/ciman</defaultValue>
45 </hudson.model.StringParameterDefinition>
46 <hudson.model.StringParameterDefinition>
47 <name>GERRIT_BRANCH</name>
48 <description>Parameter to identify a Gerrit branch.
50 Note that Gerrit will override this parameter automatically if a
51 job is triggered by Gerrit.
53 <defaultValue>master</defaultValue>
54 </hudson.model.StringParameterDefinition>
55 <hudson.model.StringParameterDefinition>
56 <name>GERRIT_REFSPEC</name>
57 <description>Parameter to identify a refspec when pulling from Gerrit.
59 Note that Gerrit will override this parameter automatically if a
60 job is triggered by Gerrit.
62 <defaultValue>refs/heads/master</defaultValue>
63 </hudson.model.StringParameterDefinition>
64 <hudson.model.StringParameterDefinition>
65 <name>LFTOOLS_VERSION</name>
66 <description>Version of lftools to install. Can be a specific version like
67 '0.6.0' or a PEP-440 definition.
68 https://www.python.org/dev/peps/pep-0440/
69 For example '<1.0.0' or '>=1.0.0,<2.0.0'.
71 <defaultValue><1.0.0</defaultValue>
72 </hudson.model.StringParameterDefinition>
73 <hudson.model.StringParameterDefinition>
75 <description>Maven selector to be used by shell scripts</description>
76 <defaultValue>/w/tools/hudson.tasks.Maven_MavenInstallation/mvn33</defaultValue>
77 </hudson.model.StringParameterDefinition>
78 <hudson.model.StringParameterDefinition>
79 <name>MAVEN_OPTS</name>
80 <description>Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
83 </hudson.model.StringParameterDefinition>
84 <hudson.model.StringParameterDefinition>
85 <name>MAVEN_PARAMS</name>
86 <description>Maven parameters to pass to the mvn command.
89 </hudson.model.StringParameterDefinition>
90 <hudson.model.StringParameterDefinition>
92 <description>Maven selector to be used by shell scripts</description>
93 <defaultValue>/w/tools/hudson.tasks.Maven_MavenInstallation/mvn33/bin/mvn</defaultValue>
94 </hudson.model.StringParameterDefinition>
95 <hudson.model.StringParameterDefinition>
96 <name>STAGING_PROFILE_ID</name>
97 <description>Nexus staging profile ID.
100 </hudson.model.StringParameterDefinition>
101 <hudson.model.StringParameterDefinition>
102 <name>ARCHIVE_ARTIFACTS</name>
103 <description>Artifacts to archive to the logs server.</description>
105 </hudson.model.StringParameterDefinition>
106 <hudson.model.StringParameterDefinition>
107 <name>SONAR_MAVEN_GOAL</name>
108 <description>Maven goals to pass to the Sonar call. Typically sonar:sonar
109 however to use a specific version of the sonar-maven-plugin we
110 can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
112 <defaultValue>sonar:sonar</defaultValue>
113 </hudson.model.StringParameterDefinition>
114 </parameterDefinitions>
115 </hudson.model.ParametersDefinitionProperty>
117 <scm class="hudson.plugins.git.GitSCM">
118 <configVersion>2</configVersion>
120 <hudson.plugins.git.UserRemoteConfig>
122 <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
123 <url>git@github.com:example-org/releng/ciman</url>
124 <credentialsId>test-credential</credentialsId>
125 </hudson.plugins.git.UserRemoteConfig>
128 <hudson.plugins.git.BranchSpec>
130 </hudson.plugins.git.BranchSpec>
132 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
133 <remotePoll>false</remotePoll>
134 <gitTool>Default</gitTool>
135 <submoduleCfg class="list"/>
140 <hudson.plugins.git.extensions.impl.BuildChooserSetting>
141 <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
142 </hudson.plugins.git.extensions.impl.BuildChooserSetting>
143 <hudson.plugins.git.extensions.impl.SubmoduleOption>
144 <disableSubmodules>false</disableSubmodules>
145 <recursiveSubmodules>true</recursiveSubmodules>
146 <trackingSubmodules>false</trackingSubmodules>
147 <parentCredentials>false</parentCredentials>
149 <timeout>10</timeout>
150 </hudson.plugins.git.extensions.impl.SubmoduleOption>
151 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
154 <triggers class="vector">
155 <org.jenkinsci.plugins.ghprb.GhprbTrigger>
158 <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
164 <triggerPhrase>^recheck$</triggerPhrase>
166 <onlyTriggerPhrase>false</onlyTriggerPhrase>
167 <useGitHubHooks>true</useGitHubHooks>
168 <permitAll>true</permitAll>
169 <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
171 <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
172 <commitStatusContext>Maven Verify</commitStatusContext>
173 </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
175 </org.jenkinsci.plugins.ghprb.GhprbTrigger>
179 <command>echo "quiet=on" > "$HOME/.wgetrc"</command>
180 </hudson.tasks.Shell>
182 <targets>--version</targets>
184 <mavenName>mvn33</mavenName>
185 <usePrivateRepository>false</usePrivateRepository>
186 <settings class="jenkins.mvn.DefaultSettingsProvider"/>
187 <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
188 </hudson.tasks.Maven>
190 <command>rm "$HOME/.wgetrc"</command>
191 </hudson.tasks.Shell>
194 <propertiesContent>SONAR_HOST_URL=$SONAR_URL</propertiesContent>
197 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
199 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
200 <fileId>global-settings</fileId>
202 <variable>GLOBAL_SETTINGS_FILE</variable>
203 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
204 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
205 <fileId>aproject-settings</fileId>
207 <variable>SETTINGS_FILE</variable>
208 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
210 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
213 # SPDX-License-Identifier: EPL-1.0
214 ##############################################################################
215 # Copyright (c) 2017 The Linux Foundation and others.
217 # All rights reserved. This program and the accompanying materials
218 # are made available under the terms of the Eclipse Public License v1.0
219 # which accompanies this distribution, and is available at
220 # http://www.eclipse.org/legal/epl-v10.html
221 ##############################################################################
223 # This file contains a list of variables that are generally useful in many
224 # scripts. It is meant to be sourced in other scripts so that the variables can
227 MAVEN_OPTIONS="$(echo --show-version \
230 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
231 -Dmaven.repo.local=/tmp/r \
232 -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r)"
233 echo "$MAVEN_OPTIONS"
236 # SPDX-License-Identifier: EPL-1.0
237 ##############################################################################
238 # Copyright (c) 2017 The Linux Foundation and others.
240 # All rights reserved. This program and the accompanying materials
241 # are made available under the terms of the Eclipse Public License v1.0
242 # which accompanies this distribution, and is available at
243 # http://www.eclipse.org/legal/epl-v10.html
244 ##############################################################################
246 # This script builds a Maven project and deploys it into a staging repo which
247 # can be used to deploy elsewhere later eg. Nexus staging / snapshot repos.
249 # DO NOT enable -u because $MAVEN_PARAMS and $MAVEN_OPTIONS could be unbound.
250 # Ensure we fail the job if any steps fail.
256 # Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
257 # shellcheck disable=SC2086
260 --global-settings "$GLOBAL_SETTINGS_FILE" \
261 --settings "$SETTINGS_FILE" \
262 -DaltDeploymentRepository=staging::default::file:"$WORKSPACE"/m2repo \
263 $MAVEN_OPTIONS $MAVEN_PARAMS
265 # Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
266 # shellcheck disable=SC2086
267 $MVN $SONAR_MAVEN_GOAL \
268 -Dsonar -Dsonar.host.url="$SONAR_HOST_URL" \
269 --global-settings "$GLOBAL_SETTINGS_FILE" \
270 --settings "$SETTINGS_FILE" \
271 -DaltDeploymentRepository=staging::default::file:"$WORKSPACE"/m2repo \
272 $MAVEN_OPTIONS $MAVEN_PARAMS
274 </hudson.tasks.Shell>
277 set +e # DO NOT cause build failure if any of the rm calls fail.
279 rm "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
281 # In some cases we use the lf-provide-maven-settings macro to produce
282 # a "$HOME/.netrc" file containing credentials. Remove that file here
284 rm "$HOME/.netrc"
286 # DO NOT fail build if any of the above lines fail.
289 </hudson.tasks.Shell>
292 <hudson.plugins.jacoco.JacocoPublisher plugin="jacoco">
293 <execPattern>**/**.exec</execPattern>
294 <classPattern>**/classes</classPattern>
295 <sourcePattern>**/src/main/java</sourcePattern>
296 <changeBuildStatus>false</changeBuildStatus>
298 <exclusionPattern>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</exclusionPattern>
299 <maximumBranchCoverage>10</maximumBranchCoverage>
300 <minimumBranchCoverage>20</minimumBranchCoverage>
301 <maximumMethodCoverage>50</maximumMethodCoverage>
302 <minimumMethodCoverage>40</minimumMethodCoverage>
303 </hudson.plugins.jacoco.JacocoPublisher>
304 <hudson.plugins.findbugs.FindBugsPublisher plugin="findbugs">
305 <isRankActivated>false</isRankActivated>
310 <thresholdLimit>low</thresholdLimit>
311 <pluginName>[FINDBUGS] </pluginName>
313 <canRunOnFailed>false</canRunOnFailed>
314 <useStableBuildAsReference>false</useStableBuildAsReference>
315 <usePreviousBuildAsReference>false</usePreviousBuildAsReference>
316 <useDeltaValues>false</useDeltaValues>
320 <unstableTotalNormal/>
327 <shouldDetectModules>false</shouldDetectModules>
328 <dontComputeNew>true</dontComputeNew>
329 <doNotResolveRelativePaths>false</doNotResolveRelativePaths>
331 </hudson.plugins.findbugs.FindBugsPublisher>
332 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
336 # SPDX-License-Identifier: EPL-1.0
337 ##############################################################################
338 # Copyright (c) 2017 The Linux Foundation and others.
340 # All rights reserved. This program and the accompanying materials
341 # are made available under the terms of the Eclipse Public License v1.0
342 # which accompanies this distribution, and is available at
343 # http://www.eclipse.org/legal/epl-v10.html
344 ##############################################################################
345 echo "---> sysstat.sh"
346 set +e # DON'T fail build if script fails.
348 OS=$(facter operatingsystem)
349 case "$OS" in
351 SYSSTAT_PATH="/var/log/sysstat"
353 # Dont run the script when systat is not enabled by default
354 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
359 SYSSTAT_PATH="/var/log/sa"
367 SAR_DIR="$WORKSPACE/archives/sar-reports"
368 mkdir -p "$SAR_DIR"
369 cp "$SYSSTAT_PATH/"* "$_"
370 # convert sar data to ascii format
371 while IFS="" read -r sarfilenum
373 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
374 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
376 # DON'T fail build if script fails.
379 </hudson.tasks.Shell>
380 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
382 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
383 <fileId>jenkins-log-archives-settings</fileId>
385 <variable>SETTINGS_FILE</variable>
386 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
388 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
391 <propertiesContent>SERVER_ID=logs</propertiesContent>
396 # SPDX-License-Identifier: EPL-1.0
397 ##############################################################################
398 # Copyright (c) 2017 The Linux Foundation and others.
400 # All rights reserved. This program and the accompanying materials
401 # are made available under the terms of the Eclipse Public License v1.0
402 # which accompanies this distribution, and is available at
403 # http://www.eclipse.org/legal/epl-v10.html
404 ##############################################################################
405 echo "---> create-netrc.sh"
407 # Ensure we fail the job if any steps fail.
410 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
411 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
412 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
413 -v x:username -o ":" -v x:password \
414 "$SETTINGS_FILE")
416 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
417 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
418 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
420 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
422 </hudson.tasks.Shell>
425 # SPDX-License-Identifier: EPL-1.0
426 ##############################################################################
427 # Copyright (c) 2017 The Linux Foundation and others.
429 # All rights reserved. This program and the accompanying materials
430 # are made available under the terms of the Eclipse Public License v1.0
431 # which accompanies this distribution, and is available at
432 # http://www.eclipse.org/legal/epl-v10.html
433 ##############################################################################
434 echo "---> lftools-install.sh"
436 # Script to install lftools via a version passed in via lf-infra-parameters
438 # Required parameters:
440 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
441 # set to a strict version number like '1.2.3' or using
442 # PEP-440 definitions.
446 # >=1.0.0,<2.0.0
448 # By default a released version of lftools should always be used.
449 # The purpose of the 2 variables below is so that lftools devs can test
450 # unreleased versions of lftools. There are 2 methods to install a dev version
453 # 1) gerrit patch: Used to test a patch that has not yet been merged.
454 # To do this set something like this:
455 # LFTOOLS_MODE=gerrit
456 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
458 # 2) git branch: Used to install an lftools version from a specific branch.
459 # To use this set the variables as follows:
461 # LFTOOLS_REFSPEC=master
463 # 3) release : The intended use case and default setting.
464 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
466 LFTOOLS_MODE=release # release | git | gerrit
467 LFTOOLS_REFSPEC=master
469 # Ensure we fail the job if any steps fail.
470 # DO NOT set -u as virtualenv's activate script has unbound variables
473 virtualenv --quiet "/tmp/v/lftools"
474 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
475 source "/tmp/v/lftools/bin/activate"
476 pip install --quiet --upgrade pip
478 case $LFTOOLS_MODE in
480 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
482 git fetch origin "$LFTOOLS_REFSPEC"
483 git checkout FETCH_HEAD
484 pip install --quiet --upgrade -r requirements.txt
485 pip install --quiet --upgrade -e .
490 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
494 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
495 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
498 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
504 # pipdeptree prints out a lot of information because lftools pulls in many
505 # dependencies. Let's only print it if we want to debug.
506 # echo "----> Pip Dependency Tree"
507 # pip install --quiet --upgrade pipdeptree
511 # SPDX-License-Identifier: EPL-1.0
512 ##############################################################################
513 # Copyright (c) 2017 The Linux Foundation and others.
515 # All rights reserved. This program and the accompanying materials
516 # are made available under the terms of the Eclipse Public License v1.0
517 # which accompanies this distribution, and is available at
518 # http://www.eclipse.org/legal/epl-v10.html
519 ##############################################################################
520 echo "---> logs-deploy.sh"
522 # Ensure we fail the job if any steps fail.
525 set -x # Trace commands for this script to make debugging easier.
527 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
528 LOGS_SERVER="${LOGS_SERVER:-None}"
530 if [ "${LOGS_SERVER}" == 'None' ]
532 set +x # Disable trace since we no longer need it
534 echo "WARNING: Logging server not set"
536 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
537 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
538 BUILD_URL="${BUILD_URL}"
540 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
541 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
543 set +x # Disable trace since we no longer need it.
545 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
548 </hudson.tasks.Shell>
551 # SPDX-License-Identifier: EPL-1.0
552 ##############################################################################
553 # Copyright (c) 2017 The Linux Foundation and others.
555 # All rights reserved. This program and the accompanying materials
556 # are made available under the terms of the Eclipse Public License v1.0
557 # which accompanies this distribution, and is available at
558 # http://www.eclipse.org/legal/epl-v10.html
559 ##############################################################################
561 # Clear log credential files
562 rm "$SETTINGS_FILE"
565 </hudson.tasks.Shell>
566 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
567 <regexp>^Build logs: .*</regexp>
568 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
570 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
571 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
572 <markBuildUnstable>false</markBuildUnstable>
573 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
574 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
576 <hudson.plugins.ws__cleanup.Pattern>
577 <pattern>**/*.jenkins-trigger</pattern>
579 </hudson.plugins.ws__cleanup.Pattern>
581 <deleteDirs>false</deleteDirs>
582 <cleanupMatrixParent>false</cleanupMatrixParent>
584 <cleanWhenSuccess>true</cleanWhenSuccess>
585 <cleanWhenUnstable>true</cleanWhenUnstable>
586 <cleanWhenFailure>true</cleanWhenFailure>
587 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
588 <cleanWhenAborted>true</cleanWhenAborted>
589 <notFailBuild>true</notFailBuild>
590 </hudson.plugins.ws__cleanup.WsCleanup>
593 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
594 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
595 <timeoutMinutes>30</timeoutMinutes>
596 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
597 <failBuild>true</failBuild>
598 <writingDescription>false</writingDescription>
599 <timeoutPercentage>0</timeoutPercentage>
600 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
601 <timeoutType>absolute</timeoutType>
602 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
603 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
604 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
605 <user>test-credential</user>
606 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
607 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
608 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
610 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
611 <fileId>npmrc</fileId>
612 <targetLocation>$HOME/.npmrc</targetLocation>
614 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
616 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>