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 <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github">
13 <projectUrl>$GIT_URL/$GERRIT_PROJECT/example-org/releng/ciman</projectUrl>
15 </com.coravy.hudson.plugins.github.GithubProjectProperty>
16 <hudson.model.ParametersDefinitionProperty>
17 <parameterDefinitions>
18 <hudson.model.StringParameterDefinition>
20 <description>Parameter to identify a Gerrit project. This is typically the
21 project repo path as exists in Gerrit.
22 For example: ofextensions/circuitsw
24 <defaultValue>releng/ciman</defaultValue>
25 </hudson.model.StringParameterDefinition>
26 <hudson.model.StringParameterDefinition>
28 <description>Stream is often set to the same name as 'branch' but can
29 sometimes be used as a name representing a project's release code
32 <defaultValue>master</defaultValue>
33 </hudson.model.StringParameterDefinition>
34 <hudson.model.StringParameterDefinition>
35 <name>GERRIT_PROJECT</name>
36 <description>Parameter to identify Gerrit project. This is typically the
37 project repo path as exists in Gerrit.
38 For example: ofextensions/circuitsw
40 Note that Gerrit will override this parameter automatically if a
41 job is triggered by Gerrit.
43 <defaultValue>releng/ciman</defaultValue>
44 </hudson.model.StringParameterDefinition>
45 <hudson.model.StringParameterDefinition>
46 <name>GERRIT_BRANCH</name>
47 <description>Parameter to identify a Gerrit branch.
49 Note that Gerrit will override this parameter automatically if a
50 job is triggered by Gerrit.
52 <defaultValue>master</defaultValue>
53 </hudson.model.StringParameterDefinition>
54 <hudson.model.StringParameterDefinition>
55 <name>GERRIT_REFSPEC</name>
56 <description>Parameter to identify a refspec when pulling from Gerrit.
58 Note that Gerrit will override this parameter automatically if a
59 job is triggered by Gerrit.
61 <defaultValue>refs/heads/master</defaultValue>
62 </hudson.model.StringParameterDefinition>
63 <hudson.model.StringParameterDefinition>
64 <name>LFTOOLS_VERSION</name>
65 <description>Version of lftools to install. Can be a specific version like
66 '0.6.0' or a PEP-440 definition.
67 https://www.python.org/dev/peps/pep-0440/
68 For example '<1.0.0' or '>=1.0.0,<2.0.0'.
70 <defaultValue><1.0.0</defaultValue>
71 </hudson.model.StringParameterDefinition>
72 </parameterDefinitions>
73 </hudson.model.ParametersDefinitionProperty>
75 <scm class="hudson.plugins.git.GitSCM">
76 <configVersion>2</configVersion>
78 <hudson.plugins.git.UserRemoteConfig>
80 <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
81 <url>git@github.com:example-org/releng/ciman</url>
82 <credentialsId>test-credential</credentialsId>
83 </hudson.plugins.git.UserRemoteConfig>
86 <hudson.plugins.git.BranchSpec>
88 </hudson.plugins.git.BranchSpec>
90 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
91 <remotePoll>false</remotePoll>
92 <gitTool>Default</gitTool>
93 <submoduleCfg class="list"/>
98 <hudson.plugins.git.extensions.impl.BuildChooserSetting>
99 <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
100 </hudson.plugins.git.extensions.impl.BuildChooserSetting>
101 <hudson.plugins.git.extensions.impl.SubmoduleOption>
102 <disableSubmodules>false</disableSubmodules>
103 <recursiveSubmodules>true</recursiveSubmodules>
104 <trackingSubmodules>false</trackingSubmodules>
105 <parentCredentials>false</parentCredentials>
107 <timeout>10</timeout>
108 </hudson.plugins.git.extensions.impl.SubmoduleOption>
109 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
112 <triggers class="vector">
113 <org.jenkinsci.plugins.ghprb.GhprbTrigger>
116 <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
122 <triggerPhrase>^jjb-deploy (?!\*+$).+$</triggerPhrase>
124 <onlyTriggerPhrase>true</onlyTriggerPhrase>
125 <useGitHubHooks>true</useGitHubHooks>
126 <permitAll>true</permitAll>
127 <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
129 <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
130 <commitStatusContext>JJB Deploy Job</commitStatusContext>
131 </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
133 </org.jenkinsci.plugins.ghprb.GhprbTrigger>
138 <propertiesContent>PIP_PACKAGES=jenkins-job-builder</propertiesContent>
143 # SPDX-License-Identifier: EPL-1.0
144 ##############################################################################
145 # Copyright (c) 2017 The Linux Foundation and others.
147 # All rights reserved. This program and the accompanying materials
148 # are made available under the terms of the Eclipse Public License v1.0
149 # which accompanies this distribution, and is available at
150 # http://www.eclipse.org/legal/epl-v10.html
151 ##############################################################################
152 # pip install packages into a virtualenv using the first listed package as venv name
154 # PIP_PACKAGES is a space separated list of pypi packages to install. The first
155 # listed package is used as the virtualenv directory name.
156 echo "---> pip-install.sh"
158 # Ensure we fail the job if any steps fail.
159 # DO NOT set -u as virtualenv's activate script has unbound variables
162 # Install git-review using virtualenv to the latest version that supports
163 # --reviewers option, available through pip install. Existing minion image has a
164 # version that does not have it.
165 virtualenv "/tmp/v/${PIP_PACKAGES%% *}"
166 # shellcheck source=/tmp/v/venv/bin/activate disable=SC1091
167 source "/tmp/v/${PIP_PACKAGES%% *}/bin/activate"
168 pip install --quiet --upgrade pip
169 pip install --quiet --upgrade pipdeptree
171 # PIP_PACKAGES needs to be passed through as a space separated list of packages
172 # shellcheck disable=SC2086
173 pip install --upgrade $PIP_PACKAGES
175 echo "----> Pip Dependency Tree"
178 </hudson.tasks.Shell>
179 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
181 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
182 <fileId>jjbini-sandbox</fileId>
183 <targetLocation>$HOME/.config/jenkins_jobs/jenkins_jobs.ini</targetLocation>
185 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
187 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
190 # SPDX-License-Identifier: EPL-1.0
191 ##############################################################################
192 # Copyright (c) 2017 The Linux Foundation and others.
194 # All rights reserved. This program and the accompanying materials
195 # are made available under the terms of the Eclipse Public License v1.0
196 # which accompanies this distribution, and is available at
197 # http://www.eclipse.org/legal/epl-v10.html
198 ##############################################################################
199 # Push a job to jenkins-sandbox via Gerrit / GitHub comment
200 # Comment Pattern: jjb-deploy JOB_NAME
201 # JOB_NAME: Can also include * wildcards too. Additional parameters are ignored.
202 echo "---> jjb-deploy-job.sh"
204 # Ensure we fail the job if any steps fail.
207 # shellcheck source=/tmp/v/jenkins-job-builder/bin/activate disable=SC1091
208 source "/tmp/v/jenkins-job-builder/bin/activate"
210 echo "-----> Fetching project"
211 git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
213 # If not Gerrit Trigger than assume GitHub
214 COMMENT="${GERRIT_EVENT_COMMENT_TEXT:-$ghprbCommentBody}"
215 JOB_NAME=$(echo "$COMMENT" | grep jjb-deploy | awk '{print $2}')
217 # Strip all * characters to prevent pushing all jobs to Jenkins
218 if [ -z "${JOB_NAME//\*/}" ]; then
219 echo "ERROR: JOB_NAME cannot be empty or '*'."
223 jenkins-jobs update --recursive --workers 4 jjb/ "$JOB_NAME"
225 </hudson.tasks.Shell>
228 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
232 # SPDX-License-Identifier: EPL-1.0
233 ##############################################################################
234 # Copyright (c) 2017 The Linux Foundation and others.
236 # All rights reserved. This program and the accompanying materials
237 # are made available under the terms of the Eclipse Public License v1.0
238 # which accompanies this distribution, and is available at
239 # http://www.eclipse.org/legal/epl-v10.html
240 ##############################################################################
241 echo "---> sysstat.sh"
242 set +e # DON'T fail build if script fails.
244 OS=$(facter operatingsystem)
245 case "$OS" in
247 SYSSTAT_PATH="/var/log/sysstat"
249 # Dont run the script when systat is not enabled by default
250 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
255 SYSSTAT_PATH="/var/log/sa"
263 SAR_DIR="$WORKSPACE/archives/sar-reports"
264 mkdir -p "$SAR_DIR"
265 cp "$SYSSTAT_PATH/"* "$_"
266 # convert sar data to ascii format
267 while IFS="" read -r sarfilenum
269 [ -f "$sarfilenum" ] && LC_TIME=POSIX sar -A -f "$sarfilenum" > "$SAR_DIR/sar${sarfilenum//[!0-9]/}"
270 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
272 # DON'T fail build if script fails.
275 </hudson.tasks.Shell>
276 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
278 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
279 <fileId>jenkins-log-archives-settings</fileId>
281 <variable>SETTINGS_FILE</variable>
282 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
284 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
287 <propertiesContent>SERVER_ID=logs</propertiesContent>
292 # SPDX-License-Identifier: EPL-1.0
293 ##############################################################################
294 # Copyright (c) 2017 The Linux Foundation and others.
296 # All rights reserved. This program and the accompanying materials
297 # are made available under the terms of the Eclipse Public License v1.0
298 # which accompanies this distribution, and is available at
299 # http://www.eclipse.org/legal/epl-v10.html
300 ##############################################################################
301 echo "---> create-netrc.sh"
303 # Ensure we fail the job if any steps fail.
306 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
307 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
308 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
309 -v x:username -o ":" -v x:password \
310 "$SETTINGS_FILE")
312 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
313 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
314 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
316 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
318 </hudson.tasks.Shell>
321 # SPDX-License-Identifier: EPL-1.0
322 ##############################################################################
323 # Copyright (c) 2017 The Linux Foundation and others.
325 # All rights reserved. This program and the accompanying materials
326 # are made available under the terms of the Eclipse Public License v1.0
327 # which accompanies this distribution, and is available at
328 # http://www.eclipse.org/legal/epl-v10.html
329 ##############################################################################
330 echo "---> lftools-install.sh"
332 # Script to install lftools via a version passed in via lf-infra-parameters
334 # Required parameters:
336 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
337 # set to a strict version number like '1.2.3' or using
338 # PEP-440 definitions.
342 # >=1.0.0,<2.0.0
344 # By default a released version of lftools should always be used.
345 # The purpose of the 2 variables below is so that lftools devs can test
346 # unreleased versions of lftools. There are 2 methods to install a dev version
349 # 1) gerrit patch: Used to test a patch that has not yet been merged.
350 # To do this set something like this:
351 # LFTOOLS_MODE=gerrit
352 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
354 # 2) git branch: Used to install an lftools version from a specific branch.
355 # To use this set the variables as follows:
357 # LFTOOLS_REFSPEC=master
359 # 3) release : The intended use case and default setting.
360 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
362 LFTOOLS_MODE=release # release | git | gerrit
363 LFTOOLS_REFSPEC=master
365 # Ensure we fail the job if any steps fail.
366 # DO NOT set -u as virtualenv's activate script has unbound variables
369 virtualenv --quiet "/tmp/v/lftools"
370 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
371 source "/tmp/v/lftools/bin/activate"
372 pip install --quiet --upgrade pip
374 case $LFTOOLS_MODE in
376 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
378 git fetch origin "$LFTOOLS_REFSPEC"
379 git checkout FETCH_HEAD
380 pip install --quiet --upgrade -r requirements.txt
381 pip install --quiet --upgrade -e .
386 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
390 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
391 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
394 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
400 # pipdeptree prints out a lot of information because lftools pulls in many
401 # dependencies. Let's only print it if we want to debug.
402 # echo "----> Pip Dependency Tree"
403 # pip install --quiet --upgrade pipdeptree
407 # SPDX-License-Identifier: EPL-1.0
408 ##############################################################################
409 # Copyright (c) 2017 The Linux Foundation and others.
411 # All rights reserved. This program and the accompanying materials
412 # are made available under the terms of the Eclipse Public License v1.0
413 # which accompanies this distribution, and is available at
414 # http://www.eclipse.org/legal/epl-v10.html
415 ##############################################################################
416 echo "---> logs-deploy.sh"
418 # Ensure we fail the job if any steps fail.
421 set -x # Trace commands for this script to make debugging easier.
423 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
424 LOGS_SERVER="${LOGS_SERVER:-None}"
426 if [ "${LOGS_SERVER}" == 'None' ]
428 set +x # Disable trace since we no longer need it
430 echo "WARNING: Logging server not set"
432 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
433 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
434 BUILD_URL="${BUILD_URL}"
436 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
437 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
439 set +x # Disable trace since we no longer need it.
441 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
444 </hudson.tasks.Shell>
447 # SPDX-License-Identifier: EPL-1.0
448 ##############################################################################
449 # Copyright (c) 2017 The Linux Foundation and others.
451 # All rights reserved. This program and the accompanying materials
452 # are made available under the terms of the Eclipse Public License v1.0
453 # which accompanies this distribution, and is available at
454 # http://www.eclipse.org/legal/epl-v10.html
455 ##############################################################################
457 # Clear log credential files
458 rm "$SETTINGS_FILE"
461 </hudson.tasks.Shell>
462 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
463 <regexp>^Build logs: .*</regexp>
464 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
466 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
467 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
468 <markBuildUnstable>false</markBuildUnstable>
469 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
470 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
472 <hudson.plugins.ws__cleanup.Pattern>
473 <pattern>**/*.jenkins-trigger</pattern>
475 </hudson.plugins.ws__cleanup.Pattern>
477 <deleteDirs>false</deleteDirs>
478 <cleanupMatrixParent>false</cleanupMatrixParent>
480 <cleanWhenSuccess>true</cleanWhenSuccess>
481 <cleanWhenUnstable>true</cleanWhenUnstable>
482 <cleanWhenFailure>true</cleanWhenFailure>
483 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
484 <cleanWhenAborted>true</cleanWhenAborted>
485 <notFailBuild>true</notFailBuild>
486 </hudson.plugins.ws__cleanup.WsCleanup>
489 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
490 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
491 <timeoutMinutes>5</timeoutMinutes>
492 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
493 <failBuild>true</failBuild>
494 <writingDescription>false</writingDescription>
495 <timeoutPercentage>0</timeoutPercentage>
496 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
497 <timeoutType>absolute</timeoutType>
498 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
499 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
500 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
501 <user>test-credential</user>
502 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
503 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
504 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
506 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
507 <fileId>npmrc</fileId>
508 <targetLocation>$HOME/.npmrc</targetLocation>
510 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
512 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>