Add support for Sonatype CLM plugin
Sonatype Component Lifecycle Management Plugin is a plugin that adds Jenkins support to the Sonatype CLM service. For this plugin to be useful it requires access to a Sonatype CLM server. See: http://www.sonatype.com/clm/overview Change-Id: Ie1eb7ab465f38c71230bf14c7af3cf89e928abe0 Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
6c3cf55400
commit
56db5a2789
|
@ -1871,3 +1871,56 @@ def sonar(parser, xml_parent, data):
|
|||
XML.SubElement(sonar, 'javaOpts').text = data.get('java-opts', '')
|
||||
if 'jdk' in data:
|
||||
XML.SubElement(sonar, 'jdk').text = data['jdk']
|
||||
|
||||
|
||||
def sonatype_clm(parser, xml_parent, data):
|
||||
"""yaml: sonatype-clm
|
||||
Requires the Jenkins :jenkins-wiki:`Sonatype CLM Plugin
|
||||
<Sonatype+CLM+%28formerly+Insight+for+CI%29>`.
|
||||
|
||||
:arg str application-name: Determines the policy elements to associate
|
||||
with this build. (Required)
|
||||
:arg bool fail-on-clm-server-failure: Controls the build outcome if there
|
||||
is a failure in communicating with the CLM server. (Default: false)
|
||||
:arg str stage: Controls the stage the policy evaluation will be run
|
||||
against on the CLM server. Valid stages: build, stage-release, release,
|
||||
operate. (Default: build)
|
||||
:arg str scan-targets: Pattern of files to include for scanning. (optional)
|
||||
:arg str module-excludes: Pattern of files to exclude. (optional)
|
||||
:arg str advanced-options: Options to be set on a case-by-case basis as
|
||||
advised by Sonatype Support. (optional)
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/builders/fixtures/sonatype-clm01.yaml
|
||||
"""
|
||||
clm = XML.SubElement(xml_parent,
|
||||
'com.sonatype.insight.ci.hudson.PreBuildScan')
|
||||
clm.set('plugin', 'sonatype-clm-ci')
|
||||
|
||||
if 'application-name' not in data:
|
||||
raise MissingAttributeError("application-name",
|
||||
"builders.sonatype-clm")
|
||||
XML.SubElement(clm, 'billOfMaterialsToken').text = str(
|
||||
data['application-name'])
|
||||
XML.SubElement(clm, 'failOnClmServerFailures').text = str(
|
||||
data.get('fail-on-clm-server-failure', False)).lower()
|
||||
|
||||
SUPPORTED_STAGES = ['build', 'stage-release', 'release', 'operate']
|
||||
stage = str(data.get('stage', 'build')).lower()
|
||||
if stage not in SUPPORTED_STAGES:
|
||||
raise InvalidAttributeError("stage",
|
||||
stage,
|
||||
"builders.sonatype-clm",
|
||||
SUPPORTED_STAGES)
|
||||
XML.SubElement(clm, 'stageId').text = stage
|
||||
|
||||
# Path Configs
|
||||
path_config = XML.SubElement(clm,
|
||||
'pathConfig')
|
||||
XML.SubElement(path_config, 'scanTargets').text = str(
|
||||
data.get('scan-targets', '')).lower()
|
||||
XML.SubElement(path_config, 'moduleExcludes').text = str(
|
||||
data.get('module-excludes', '')).lower()
|
||||
XML.SubElement(path_config, 'scanProperties').text = str(
|
||||
data.get('advanced-options', '')).lower()
|
||||
|
|
|
@ -71,6 +71,7 @@ jenkins_jobs.builders =
|
|||
shell=jenkins_jobs.modules.builders:shell
|
||||
shining-panda=jenkins_jobs.modules.builders:shining_panda
|
||||
sonar=jenkins_jobs.modules.builders:sonar
|
||||
sonatype-clm=jenkins_jobs.modules.builders:sonatype_clm
|
||||
system-groovy=jenkins_jobs.modules.builders:system_groovy
|
||||
trigger-builds=jenkins_jobs.modules.builders:trigger_builds
|
||||
jenkins_jobs.reporters =
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<com.sonatype.insight.ci.hudson.PreBuildScan plugin="sonatype-clm-ci">
|
||||
<billOfMaterialsToken>jenkins-job-builder</billOfMaterialsToken>
|
||||
<failOnClmServerFailures>true</failOnClmServerFailures>
|
||||
<stageId>release</stageId>
|
||||
<pathConfig>
|
||||
<scanTargets>**/*.jar</scanTargets>
|
||||
<moduleExcludes>**/my-module/target/**</moduleExcludes>
|
||||
<scanProperties>test</scanProperties>
|
||||
</pathConfig>
|
||||
</com.sonatype.insight.ci.hudson.PreBuildScan>
|
||||
</builders>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
builders:
|
||||
- sonatype-clm:
|
||||
application-name: jenkins-job-builder
|
||||
fail-on-clm-server-failure: true
|
||||
stage: release
|
||||
scan-targets: '**/*.jar'
|
||||
module-excludes: '**/my-module/target/**'
|
||||
advanced-options: 'test'
|
Loading…
Reference in New Issue