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>
13 <projectUrl>$GIT_URL/$GERRIT_PROJECT/example-org/releng/ciman</projectUrl>
14 </com.coravy.hudson.plugins.github.GithubProjectProperty>
15 <hudson.model.ParametersDefinitionProperty>
16 <parameterDefinitions>
17 <hudson.model.StringParameterDefinition>
19 <description>Parameter to identify a Gerrit project. This is typically the
20 project repo path as exists in Gerrit.
21 For example: ofextensions/circuitsw
23 <defaultValue>releng/ciman</defaultValue>
24 </hudson.model.StringParameterDefinition>
25 <hudson.model.StringParameterDefinition>
27 <description>Stream is often set to the same name as 'branch' but can
28 sometimes be used as a name representing a project's release code
31 <defaultValue>master</defaultValue>
32 </hudson.model.StringParameterDefinition>
33 <hudson.model.StringParameterDefinition>
34 <name>GERRIT_PROJECT</name>
35 <description>Parameter to identify Gerrit project. This is typically the
36 project repo path as exists in Gerrit.
37 For example: ofextensions/circuitsw
39 Note that Gerrit will override this parameter automatically if a
40 job is triggered by Gerrit.
42 <defaultValue>releng/ciman</defaultValue>
43 </hudson.model.StringParameterDefinition>
44 <hudson.model.StringParameterDefinition>
45 <name>GERRIT_BRANCH</name>
46 <description>Parameter to identify a Gerrit branch.
48 Note that Gerrit will override this parameter automatically if a
49 job is triggered by Gerrit.
51 <defaultValue>master</defaultValue>
52 </hudson.model.StringParameterDefinition>
53 <hudson.model.StringParameterDefinition>
54 <name>GERRIT_REFSPEC</name>
55 <description>Parameter to identify a refspec when pulling from Gerrit.
57 Note that Gerrit will override this parameter automatically if a
58 job is triggered by Gerrit.
60 <defaultValue>refs/heads/master</defaultValue>
61 </hudson.model.StringParameterDefinition>
62 <hudson.model.StringParameterDefinition>
63 <name>LFTOOLS_VERSION</name>
64 <description>Version of lftools to install. Can be a specific version like
65 '0.6.0' or a PEP-440 definition.
66 https://www.python.org/dev/peps/pep-0440/
67 For example '<1.0.0' or '>=1.0.0,<2.0.0'.
69 <defaultValue><1.0.0</defaultValue>
70 </hudson.model.StringParameterDefinition>
71 </parameterDefinitions>
72 </hudson.model.ParametersDefinitionProperty>
74 <scm class="hudson.plugins.git.GitSCM">
75 <configVersion>2</configVersion>
77 <hudson.plugins.git.UserRemoteConfig>
79 <refspec>+refs/pull/*:refs/remotes/origin/pr/*</refspec>
80 <url>git@github.com:example-org/releng/ciman</url>
81 <credentialsId>test-credential</credentialsId>
82 </hudson.plugins.git.UserRemoteConfig>
85 <hudson.plugins.git.BranchSpec>
87 </hudson.plugins.git.BranchSpec>
90 <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
91 <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
92 <authorOrCommitter>false</authorOrCommitter>
93 <wipeOutWorkspace>true</wipeOutWorkspace>
94 <pruneBranches>false</pruneBranches>
95 <remotePoll>false</remotePoll>
96 <gitTool>Default</gitTool>
97 <submoduleCfg class="list"/>
102 <skipTag>true</skipTag>
104 <useShallowClone>false</useShallowClone>
105 <ignoreNotifyCommit>false</ignoreNotifyCommit>
107 <hudson.plugins.git.extensions.impl.SubmoduleOption>
108 <disableSubmodules>false</disableSubmodules>
109 <recursiveSubmodules>true</recursiveSubmodules>
110 <trackingSubmodules>false</trackingSubmodules>
112 <timeout>10</timeout>
113 </hudson.plugins.git.extensions.impl.SubmoduleOption>
114 <hudson.plugins.git.extensions.impl.WipeWorkspace/>
117 <triggers class="vector">
118 <org.jenkinsci.plugins.ghprb.GhprbTrigger>
121 <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
125 <triggerPhrase>^jjb-deploy (?!\*+$).+$</triggerPhrase>
126 <onlyTriggerPhrase>true</onlyTriggerPhrase>
127 <useGitHubHooks>true</useGitHubHooks>
128 <permitAll>true</permitAll>
129 <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
131 <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
132 <commitStatusContext>JJB Deploy Job</commitStatusContext>
133 </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
135 </org.jenkinsci.plugins.ghprb.GhprbTrigger>
140 <propertiesContent>PIP_PACKAGES=jenkins-job-builder</propertiesContent>
145 # SPDX-License-Identifier: EPL-1.0
146 ##############################################################################
147 # Copyright (c) 2017 The Linux Foundation and others.
149 # All rights reserved. This program and the accompanying materials
150 # are made available under the terms of the Eclipse Public License v1.0
151 # which accompanies this distribution, and is available at
152 # http://www.eclipse.org/legal/epl-v10.html
153 ##############################################################################
154 # pip install packages into a virtualenv using the first listed package as venv name
156 # PIP_PACKAGES is a space separated list of pypi packages to install. The first
157 # listed package is used as the virtualenv directory name.
158 echo "---> pip-install.sh"
160 # Ensure we fail the job if any steps fail.
161 # DO NOT set -u as virtualenv's activate script has unbound variables
164 # Install git-review using virtualenv to the latest version that supports
165 # --reviewers option, available through pip install. Existing minion image has a
166 # version that does not have it.
167 virtualenv "/tmp/v/${PIP_PACKAGES%% *}"
168 # shellcheck source=/tmp/v/venv/bin/activate disable=SC1091
169 source "/tmp/v/${PIP_PACKAGES%% *}/bin/activate"
170 pip install --quiet --upgrade pip
171 pip install --quiet --upgrade pipdeptree
173 # PIP_PACKAGES needs to be passed through as a space separated list of packages
174 # shellcheck disable=SC2086
175 pip install --upgrade $PIP_PACKAGES
177 echo "----> Pip Dependency Tree"
180 </hudson.tasks.Shell>
181 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
183 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
184 <fileId>jjbini-sandbox</fileId>
185 <targetLocation>$HOME/.config/jenkins_jobs/jenkins_jobs.ini</targetLocation>
187 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
189 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
192 # SPDX-License-Identifier: EPL-1.0
193 ##############################################################################
194 # Copyright (c) 2017 The Linux Foundation and others.
196 # All rights reserved. This program and the accompanying materials
197 # are made available under the terms of the Eclipse Public License v1.0
198 # which accompanies this distribution, and is available at
199 # http://www.eclipse.org/legal/epl-v10.html
200 ##############################################################################
201 # Push a job to jenkins-sandbox via Gerrit / GitHub comment
202 # Comment Pattern: jjb-deploy JOB_NAME
203 # JOB_NAME: Can also include * wildcards too. Additional parameters are ignored.
204 echo "---> jjb-deploy-job.sh"
206 # Ensure we fail the job if any steps fail.
209 # shellcheck source=/tmp/v/jenkins-job-builder/bin/activate disable=SC1091
210 source "/tmp/v/jenkins-job-builder/bin/activate"
212 echo "-----> Fetching project"
213 git fetch origin "$GERRIT_REFSPEC" && git checkout FETCH_HEAD
215 # If not Gerrit Trigger than assume GitHub
216 COMMENT="${GERRIT_EVENT_COMMENT_TEXT:-$ghprbCommentBody}"
217 JOB_NAME=$(echo "$COMMENT" | grep jjb-deploy | awk '{print $2}')
219 # Strip all * characters to prevent pushing all jobs to Jenkins
220 if [ -z "${JOB_NAME//\*/}" ]; then
221 echo "ERROR: JOB_NAME cannot be empty or '*'."
225 jenkins-jobs update --recursive --workers 4 jjb/ "$JOB_NAME"
227 </hudson.tasks.Shell>
230 <org.jenkinsci.plugins.postbuildscript.PostBuildScript>
234 # SPDX-License-Identifier: EPL-1.0
235 ##############################################################################
236 # Copyright (c) 2017 The Linux Foundation and others.
238 # All rights reserved. This program and the accompanying materials
239 # are made available under the terms of the Eclipse Public License v1.0
240 # which accompanies this distribution, and is available at
241 # http://www.eclipse.org/legal/epl-v10.html
242 ##############################################################################
243 echo "---> sysstat.sh"
244 set +e # DON'T fail build if script fails.
246 OS=$(facter operatingsystem)
247 case "$OS" in
249 SYSSTAT_PATH="/var/log/sysstat"
251 # Dont run the script when systat is not enabled by default
252 if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
257 SYSSTAT_PATH="/var/log/sa"
265 SAR_DIR="$WORKSPACE/archives/sar-reports"
266 mkdir -p "$SAR_DIR"
267 cp "$SYSSTAT_PATH/"* "$_"
268 # convert sar data to ascii format
269 while IFS="" read -r s
271 [ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
272 done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
274 # DON'T fail build if script fails.
277 </hudson.tasks.Shell>
278 <org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep plugin="config-file-provider">
280 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
281 <fileId>jenkins-log-archives-settings</fileId>
283 <variable>SETTINGS_FILE</variable>
284 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
286 </org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep>
289 <propertiesContent>SERVER_ID=logs</propertiesContent>
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 "---> create-netrc.sh"
305 # Ensure we fail the job if any steps fail.
308 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
309 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
310 -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
311 -v x:username -o ":" -v x:password \
312 "$SETTINGS_FILE")
314 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
315 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
316 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
318 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
320 </hudson.tasks.Shell>
323 # SPDX-License-Identifier: EPL-1.0
324 ##############################################################################
325 # Copyright (c) 2017 The Linux Foundation and others.
327 # All rights reserved. This program and the accompanying materials
328 # are made available under the terms of the Eclipse Public License v1.0
329 # which accompanies this distribution, and is available at
330 # http://www.eclipse.org/legal/epl-v10.html
331 ##############################################################################
332 echo "---> lftools-install.sh"
334 # Script to install lftools via a version passed in via lf-infra-parameters
336 # Required parameters:
338 # LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
339 # set to a strict version number like '1.2.3' or using
340 # PEP-440 definitions.
344 # >=1.0.0,<2.0.0
346 # By default a released version of lftools should always be used.
347 # The purpose of the 2 variables below is so that lftools devs can test
348 # unreleased versions of lftools. There are 2 methods to install a dev version
351 # 1) gerrit patch: Used to test a patch that has not yet been merged.
352 # To do this set something like this:
353 # LFTOOLS_MODE=gerrit
354 # LFTOOLS_REFSPEC=refs/changes/96/5296/7
356 # 2) git branch: Used to install an lftools version from a specific branch.
357 # To use this set the variables as follows:
359 # LFTOOLS_REFSPEC=master
361 # 3) release : The intended use case and default setting.
362 # Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
364 LFTOOLS_MODE=release # release | git | gerrit
365 LFTOOLS_REFSPEC=master
367 # Ensure we fail the job if any steps fail.
368 # DO NOT set -u as virtualenv's activate script has unbound variables
371 virtualenv --quiet "/tmp/v/lftools"
372 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
373 source "/tmp/v/lftools/bin/activate"
374 pip install --quiet --upgrade pip
376 case $LFTOOLS_MODE in
378 git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
380 git fetch origin "$LFTOOLS_REFSPEC"
381 git checkout FETCH_HEAD
382 pip install --quiet --upgrade -r requirements.txt
383 pip install --quiet --upgrade -e .
388 pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
392 if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
393 LFTOOLS_VERSION="==$LFTOOLS_VERSION"
396 pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
402 # pipdeptree prints out a lot of information because lftools pulls in many
403 # dependencies. Let's only print it if we want to debug.
404 # echo "----> Pip Dependency Tree"
405 # pip install --quiet --upgrade pipdeptree
409 # SPDX-License-Identifier: EPL-1.0
410 ##############################################################################
411 # Copyright (c) 2017 The Linux Foundation and others.
413 # All rights reserved. This program and the accompanying materials
414 # are made available under the terms of the Eclipse Public License v1.0
415 # which accompanies this distribution, and is available at
416 # http://www.eclipse.org/legal/epl-v10.html
417 ##############################################################################
418 echo "---> logs-deploy.sh"
420 # Ensure we fail the job if any steps fail.
423 set -x # Trace commands for this script to make debugging easier.
425 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
426 LOGS_SERVER="${LOGS_SERVER:-None}"
428 if [ "${LOGS_SERVER}" == 'None' ]
430 set +x # Disable trace since we no longer need it
432 echo "WARNING: Logging server not set"
434 NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
435 NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
436 BUILD_URL="${BUILD_URL}"
438 lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
439 lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
441 set +x # Disable trace since we no longer need it.
443 echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
446 </hudson.tasks.Shell>
449 # SPDX-License-Identifier: EPL-1.0
450 ##############################################################################
451 # Copyright (c) 2017 The Linux Foundation and others.
453 # All rights reserved. This program and the accompanying materials
454 # are made available under the terms of the Eclipse Public License v1.0
455 # which accompanies this distribution, and is available at
456 # http://www.eclipse.org/legal/epl-v10.html
457 ##############################################################################
459 # Clear log credential files
460 rm "$SETTINGS_FILE"
463 </hudson.tasks.Shell>
464 <hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
465 <regexp>^Build logs: .*</regexp>
466 </hudson.plugins.descriptionsetter.DescriptionSetterBuilder>
468 <scriptOnlyIfSuccess>false</scriptOnlyIfSuccess>
469 <scriptOnlyIfFailure>false</scriptOnlyIfFailure>
470 <markBuildUnstable>false</markBuildUnstable>
471 </org.jenkinsci.plugins.postbuildscript.PostBuildScript>
472 <hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
474 <hudson.plugins.ws__cleanup.Pattern>
475 <pattern>**/*.jenkins-trigger</pattern>
477 </hudson.plugins.ws__cleanup.Pattern>
479 <deleteDirs>false</deleteDirs>
480 <cleanupMatrixParent>false</cleanupMatrixParent>
482 <cleanWhenSuccess>true</cleanWhenSuccess>
483 <cleanWhenUnstable>true</cleanWhenUnstable>
484 <cleanWhenFailure>true</cleanWhenFailure>
485 <cleanWhenNotBuilt>true</cleanWhenNotBuilt>
486 <cleanWhenAborted>true</cleanWhenAborted>
487 <notFailBuild>true</notFailBuild>
488 </hudson.plugins.ws__cleanup.WsCleanup>
491 <com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsBuildWrapper/>
492 <hudson.plugins.build__timeout.BuildTimeoutWrapper>
493 <timeoutMinutes>5</timeoutMinutes>
494 <timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
495 <failBuild>true</failBuild>
496 <writingDescription>false</writingDescription>
497 <timeoutPercentage>0</timeoutPercentage>
498 <timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
499 <timeoutType>absolute</timeoutType>
500 </hudson.plugins.build__timeout.BuildTimeoutWrapper>
501 <hudson.plugins.timestamper.TimestamperBuildWrapper/>
502 <com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
503 <user>test-credential</user>
504 </com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper>
505 <jenkins.plugins.openstack.compute.JCloudsOneOffSlave/>
506 <org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper plugin="config-file-provider">
508 <org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
509 <fileId>npmrc</fileId>
510 <targetLocation>$HOME/.npmrc</targetLocation>
512 </org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
514 </org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>