summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jenkins_jobs/modules/publishers.py151
-rw-r--r--tests/publishers/fixtures/cloudfoundry-full.xml62
-rw-r--r--tests/publishers/fixtures/cloudfoundry-full.yaml39
-rw-r--r--tests/publishers/fixtures/cloudfoundry-minimal.xml31
-rw-r--r--tests/publishers/fixtures/cloudfoundry-minimal.yaml6
5 files changed, 289 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 11f2bdc4..7a5ef21f 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -666,6 +666,157 @@ def clone_workspace(registry, xml_parent, data):
XML.SubElement(cloneworkspace, 'archiveMethod').text = archive_method
+def cloud_foundry(parser, xml_parent, data):
+ """yaml: cloudfoundry
+ Pushes a project to Cloud Foundry or a CF-based platform (e.g. Stackato) at
+ the end of a build. Requires the Jenkins :jenkins-wiki:`Cloud Foundry
+ Plugin <Cloud+Foundry+Plugin>`.
+
+ :arg str target: The API endpoint of the platform you want to push to.
+ This is the URL you use to access the platform, possibly with ".api"
+ added. (required)
+ :arg str organization: An org is a development account that an individual
+ or multiple collaborators can own and use (required)
+ :arg str space: Provide users with access to a shared location for
+ application development, deployment, and maintenance (required)
+ :arg str credentials-id: credentials-id of the user (required)
+ :arg bool self-signed: Allow self-signed SSL certificates from the target
+ (default false)
+ :arg bool reset-app: Delete app before pushing app's configurations
+ (default false)
+ :arg int plugin-timeout: The time in seconds before the Cloud Foundry
+ plugin stops fetching logs and marks the build a failure (default 120)
+ :arg list create-services: Create services automatically (default '')
+
+ :create-services:
+ * **name** ('str') -- Service name (default '')
+ * **type** ('str') -- Service type (default '')
+ * **plan** ('str') -- Service plan (default '')
+ * **reset-service** ('bool') -- Delete the service before creating
+ the new one (default false)
+ :arg str value: Select to read configuration from manifest file or to enter
+ configuration in Jenkins (default 'manifestFile')
+ :arg str manifest-file: Path to manifest file (default 'manifest.yml')
+ :arg str app-name: The application's name. Default to Jenkins build name.
+ (default '')
+ :arg int memory: The application's memory usage in MB (default 512)
+ :arg str host-name: The hostname of the URI to access your application.
+ Default to app-name (default '')
+ :arg int instances: Number of instances of your application on creation
+ (default 1)
+ :arg int manifest-timeout: The time in seconds before the health-manager
+ gives up on starting the application (default 60)
+ :arg bool no-route: No URI path will be created to access the application
+ (default false)
+ :arg str app-path: Path to application (default '')
+ :arg build-pack: If your application requires a custom buildpack, you can
+ use this to specify its URL or name (default '')
+ :arg str stack: If your application requires a custom stack, you can use
+ this to specify its name. (default '')
+ :arg str command: Set a custom start command for your application
+ (default '')
+ :arg str domain: The domain of the URI to access your application
+ (default '')
+ :arg list environment-variables: Inject environment variables
+
+ :environment-variables:
+ * **key** ('str') -- Environment variable key (default '')
+ * **value** ('str') -- Environment variable value (default '')
+ :arg list services-names: Name of service instances
+
+ :services-names:
+ * **name** ('str') -- Name of the service instance (default '')
+
+ Minimal example:
+
+ .. literalinclude::
+ /../../tests/publishers/fixtures/cloudfoundry-minimal.yaml
+ :language: yaml
+
+ Full example:
+
+ .. literalinclude:: /../../tests/publishers/fixtures/cloudfoundry-full.yaml
+ :language: yaml
+ """
+ cloud_foundry = XML.SubElement(
+ xml_parent, 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher')
+ cloud_foundry.set('plugin', 'cloudfoundry')
+
+ mapping = [
+ ('target', 'target', None),
+ ('organization', 'organization', None),
+ ('space', 'cloudSpace', None),
+ ('credentials-id', 'credentialsId', None),
+ ('self-signed', 'selfSigned', False),
+ ('reset-app', 'resetIfExists', False),
+ ('timeout', 'pluginTimeout', 120),
+ ]
+ helpers.convert_mapping_to_xml(
+ cloud_foundry, data, mapping, fail_required=True)
+ XML.SubElement(cloud_foundry, 'appURIs').text = ''
+
+ create_services = XML.SubElement(cloud_foundry, 'servicesToCreate')
+ create_services_mapping = [
+ ('name', 'name', ''),
+ ('type', 'type', ''),
+ ('plan', 'plan', ''),
+ ('reset-service', 'resetService', '')]
+ for service in data.get('create-services', ''):
+ create_services_sub = XML.SubElement(
+ create_services,
+ 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service')
+ helpers.convert_mapping_to_xml(create_services_sub,
+ service,
+ create_services_mapping,
+ fail_required=True)
+
+ manifest = XML.SubElement(cloud_foundry, 'manifestChoice')
+ valid_values = ['manifestFile', 'jenkinsConfig']
+ manifest_mapping = [
+ ('value', 'value', 'manifestFile', valid_values),
+ ('manifest-file', 'manifestFile', 'manifest.yml'),
+ ('app-name', 'appName', ''),
+ ('memory', 'memory', 512),
+ ('host-name', 'hostname', ''),
+ ('instances', 'instances', 1),
+ ('manifest-timeout', 'timeout', 60),
+ ('no-route', 'noRoute', False),
+ ('app-path', 'appPath', ''),
+ ('build-pack', 'buildpack', ''),
+ ('stack', 'stack', ''),
+ ('command', 'command', ''),
+ ('domain', 'domain', ''),
+ ]
+ helpers.convert_mapping_to_xml(
+ manifest, data, manifest_mapping, fail_required=True)
+
+ if 'environment-variables' in data:
+ env_vars = XML.SubElement(manifest, 'envVars')
+ env_vars_mapping = [
+ ('key', 'key', ''),
+ ('value', 'value', '')]
+ for var in data['environment-variables']:
+ env_vars_sub = XML.SubElement(
+ env_vars,
+ 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-'
+ 'EnvironmentVariable')
+ helpers.convert_mapping_to_xml(
+ env_vars_sub, var, env_vars_mapping, fail_required=True)
+
+ if 'services-names' in data:
+ services_names = XML.SubElement(manifest, 'servicesNames')
+ service_name_mapping = [('name', 'name', '')]
+ for name in data['services-names']:
+ services_names_sub = XML.SubElement(
+ services_names,
+ 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-'
+ 'ServiceName')
+ helpers.convert_mapping_to_xml(services_names_sub,
+ name,
+ service_name_mapping,
+ fail_required=True)
+
+
def cloverphp(registry, xml_parent, data):
"""yaml: cloverphp
Capture code coverage reports from PHPUnit
diff --git a/tests/publishers/fixtures/cloudfoundry-full.xml b/tests/publishers/fixtures/cloudfoundry-full.xml
new file mode 100644
index 00000000..a5820365
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-full.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher plugin="cloudfoundry">
+ <target>https://api.stackato-rkw2.local</target>
+ <organization>AS</organization>
+ <cloudSpace>SimpleSpace</cloudSpace>
+ <credentialsId>123</credentialsId>
+ <selfSigned>true</selfSigned>
+ <resetIfExists>true</resetIfExists>
+ <pluginTimeout>240</pluginTimeout>
+ <appURIs/>
+ <servicesToCreate>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
+ <name>foo-name</name>
+ <type>foo-type</type>
+ <plan>plan1</plan>
+ <resetService>true</resetService>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
+ <name>bar-name</name>
+ <type>bar-type</type>
+ <plan>plan2</plan>
+ <resetService>false</resetService>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
+ </servicesToCreate>
+ <manifestChoice>
+ <value>jenkinsConfig</value>
+ <manifestFile>manifest.yml</manifestFile>
+ <appName>cloudfoundry</appName>
+ <memory>1024</memory>
+ <hostname>cloudfoundry</hostname>
+ <instances>5</instances>
+ <timeout>120</timeout>
+ <noRoute>true</noRoute>
+ <appPath>foo</appPath>
+ <buildpack>custom-buildpack</buildpack>
+ <stack>custom-stack</stack>
+ <command>start</command>
+ <domain>cloudfoundry.domain</domain>
+ <envVars>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
+ <key>key</key>
+ <value>value</value>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
+ <key>key2</key>
+ <value>value2</value>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
+ </envVars>
+ <servicesNames>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
+ <name>service-name</name>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
+ <name>service-name2</name>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
+ </servicesNames>
+ </manifestChoice>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/cloudfoundry-full.yaml b/tests/publishers/fixtures/cloudfoundry-full.yaml
new file mode 100644
index 00000000..9afa8115
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-full.yaml
@@ -0,0 +1,39 @@
+publishers:
+ - cloudfoundry:
+ target: https://api.stackato-rkw2.local
+ organization: AS
+ space: SimpleSpace
+ credentials-id: 123
+ self-signed: true
+ reset-app: true
+ timeout: 240
+ create-services:
+ - name: foo-name
+ type: foo-type
+ plan: plan1
+ reset-service: true
+ - name: bar-name
+ type: bar-type
+ plan: plan2
+ reset-service: false
+ value: jenkinsConfig
+ manifest-file: manifest.yml
+ app-name: cloudfoundry
+ memory: 1024
+ host-name: cloudfoundry
+ instances: 5
+ manifest-timeout: 120
+ no-route: true
+ app-path: foo
+ build-pack: custom-buildpack
+ stack: custom-stack
+ command: start
+ domain: cloudfoundry.domain
+ environment-variables:
+ - key: key
+ value: value
+ - key: key2
+ value: value2
+ services-names:
+ - name: service-name
+ - name: service-name2
diff --git a/tests/publishers/fixtures/cloudfoundry-minimal.xml b/tests/publishers/fixtures/cloudfoundry-minimal.xml
new file mode 100644
index 00000000..8a6a51f5
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-minimal.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher plugin="cloudfoundry">
+ <target>https://api.stackato-rkw2.local</target>
+ <organization>AS</organization>
+ <cloudSpace>SimpleSpace</cloudSpace>
+ <credentialsId>j89jk213</credentialsId>
+ <selfSigned>false</selfSigned>
+ <resetIfExists>false</resetIfExists>
+ <pluginTimeout>120</pluginTimeout>
+ <appURIs/>
+ <servicesToCreate/>
+ <manifestChoice>
+ <value>manifestFile</value>
+ <manifestFile>manifest.yml</manifestFile>
+ <appName/>
+ <memory>512</memory>
+ <hostname/>
+ <instances>1</instances>
+ <timeout>60</timeout>
+ <noRoute>false</noRoute>
+ <appPath/>
+ <buildpack/>
+ <stack/>
+ <command/>
+ <domain/>
+ </manifestChoice>
+ </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/cloudfoundry-minimal.yaml b/tests/publishers/fixtures/cloudfoundry-minimal.yaml
new file mode 100644
index 00000000..a96e5057
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-minimal.yaml
@@ -0,0 +1,6 @@
+publishers:
+ - cloudfoundry:
+ target: https://api.stackato-rkw2.local
+ organization: AS
+ space: SimpleSpace
+ credentials-id: j89jk213