summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-04-30 21:39:21 +0000
committerGerrit Code Review <review@openstack.org>2018-04-30 21:39:21 +0000
commit7696ea37fd65b845ef5cdfb15dcd31e907af2585 (patch)
treee7fb300260210f73ab0ce9b4c13dc7506a444010
parent30068062b24a07279981c838b952af86e772dde6 (diff)
parentfbce8ef267177946c16014492ccd8114af0ebe95 (diff)
Merge "Add support for Cloud Foundry plugin"2.0.7
-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 11f2bdc..7a5ef21 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -666,6 +666,157 @@ def clone_workspace(registry, xml_parent, data):
666 XML.SubElement(cloneworkspace, 'archiveMethod').text = archive_method 666 XML.SubElement(cloneworkspace, 'archiveMethod').text = archive_method
667 667
668 668
669def cloud_foundry(parser, xml_parent, data):
670 """yaml: cloudfoundry
671 Pushes a project to Cloud Foundry or a CF-based platform (e.g. Stackato) at
672 the end of a build. Requires the Jenkins :jenkins-wiki:`Cloud Foundry
673 Plugin <Cloud+Foundry+Plugin>`.
674
675 :arg str target: The API endpoint of the platform you want to push to.
676 This is the URL you use to access the platform, possibly with ".api"
677 added. (required)
678 :arg str organization: An org is a development account that an individual
679 or multiple collaborators can own and use (required)
680 :arg str space: Provide users with access to a shared location for
681 application development, deployment, and maintenance (required)
682 :arg str credentials-id: credentials-id of the user (required)
683 :arg bool self-signed: Allow self-signed SSL certificates from the target
684 (default false)
685 :arg bool reset-app: Delete app before pushing app's configurations
686 (default false)
687 :arg int plugin-timeout: The time in seconds before the Cloud Foundry
688 plugin stops fetching logs and marks the build a failure (default 120)
689 :arg list create-services: Create services automatically (default '')
690
691 :create-services:
692 * **name** ('str') -- Service name (default '')
693 * **type** ('str') -- Service type (default '')
694 * **plan** ('str') -- Service plan (default '')
695 * **reset-service** ('bool') -- Delete the service before creating
696 the new one (default false)
697 :arg str value: Select to read configuration from manifest file or to enter
698 configuration in Jenkins (default 'manifestFile')
699 :arg str manifest-file: Path to manifest file (default 'manifest.yml')
700 :arg str app-name: The application's name. Default to Jenkins build name.
701 (default '')
702 :arg int memory: The application's memory usage in MB (default 512)
703 :arg str host-name: The hostname of the URI to access your application.
704 Default to app-name (default '')
705 :arg int instances: Number of instances of your application on creation
706 (default 1)
707 :arg int manifest-timeout: The time in seconds before the health-manager
708 gives up on starting the application (default 60)
709 :arg bool no-route: No URI path will be created to access the application
710 (default false)
711 :arg str app-path: Path to application (default '')
712 :arg build-pack: If your application requires a custom buildpack, you can
713 use this to specify its URL or name (default '')
714 :arg str stack: If your application requires a custom stack, you can use
715 this to specify its name. (default '')
716 :arg str command: Set a custom start command for your application
717 (default '')
718 :arg str domain: The domain of the URI to access your application
719 (default '')
720 :arg list environment-variables: Inject environment variables
721
722 :environment-variables:
723 * **key** ('str') -- Environment variable key (default '')
724 * **value** ('str') -- Environment variable value (default '')
725 :arg list services-names: Name of service instances
726
727 :services-names:
728 * **name** ('str') -- Name of the service instance (default '')
729
730 Minimal example:
731
732 .. literalinclude::
733 /../../tests/publishers/fixtures/cloudfoundry-minimal.yaml
734 :language: yaml
735
736 Full example:
737
738 .. literalinclude:: /../../tests/publishers/fixtures/cloudfoundry-full.yaml
739 :language: yaml
740 """
741 cloud_foundry = XML.SubElement(
742 xml_parent, 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher')
743 cloud_foundry.set('plugin', 'cloudfoundry')
744
745 mapping = [
746 ('target', 'target', None),
747 ('organization', 'organization', None),
748 ('space', 'cloudSpace', None),
749 ('credentials-id', 'credentialsId', None),
750 ('self-signed', 'selfSigned', False),
751 ('reset-app', 'resetIfExists', False),
752 ('timeout', 'pluginTimeout', 120),
753 ]
754 helpers.convert_mapping_to_xml(
755 cloud_foundry, data, mapping, fail_required=True)
756 XML.SubElement(cloud_foundry, 'appURIs').text = ''
757
758 create_services = XML.SubElement(cloud_foundry, 'servicesToCreate')
759 create_services_mapping = [
760 ('name', 'name', ''),
761 ('type', 'type', ''),
762 ('plan', 'plan', ''),
763 ('reset-service', 'resetService', '')]
764 for service in data.get('create-services', ''):
765 create_services_sub = XML.SubElement(
766 create_services,
767 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service')
768 helpers.convert_mapping_to_xml(create_services_sub,
769 service,
770 create_services_mapping,
771 fail_required=True)
772
773 manifest = XML.SubElement(cloud_foundry, 'manifestChoice')
774 valid_values = ['manifestFile', 'jenkinsConfig']
775 manifest_mapping = [
776 ('value', 'value', 'manifestFile', valid_values),
777 ('manifest-file', 'manifestFile', 'manifest.yml'),
778 ('app-name', 'appName', ''),
779 ('memory', 'memory', 512),
780 ('host-name', 'hostname', ''),
781 ('instances', 'instances', 1),
782 ('manifest-timeout', 'timeout', 60),
783 ('no-route', 'noRoute', False),
784 ('app-path', 'appPath', ''),
785 ('build-pack', 'buildpack', ''),
786 ('stack', 'stack', ''),
787 ('command', 'command', ''),
788 ('domain', 'domain', ''),
789 ]
790 helpers.convert_mapping_to_xml(
791 manifest, data, manifest_mapping, fail_required=True)
792
793 if 'environment-variables' in data:
794 env_vars = XML.SubElement(manifest, 'envVars')
795 env_vars_mapping = [
796 ('key', 'key', ''),
797 ('value', 'value', '')]
798 for var in data['environment-variables']:
799 env_vars_sub = XML.SubElement(
800 env_vars,
801 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-'
802 'EnvironmentVariable')
803 helpers.convert_mapping_to_xml(
804 env_vars_sub, var, env_vars_mapping, fail_required=True)
805
806 if 'services-names' in data:
807 services_names = XML.SubElement(manifest, 'servicesNames')
808 service_name_mapping = [('name', 'name', '')]
809 for name in data['services-names']:
810 services_names_sub = XML.SubElement(
811 services_names,
812 'com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-'
813 'ServiceName')
814 helpers.convert_mapping_to_xml(services_names_sub,
815 name,
816 service_name_mapping,
817 fail_required=True)
818
819
669def cloverphp(registry, xml_parent, data): 820def cloverphp(registry, xml_parent, data):
670 """yaml: cloverphp 821 """yaml: cloverphp
671 Capture code coverage reports from PHPUnit 822 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 0000000..a582036
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-full.xml
@@ -0,0 +1,62 @@
1<?xml version="1.0" encoding="utf-8"?>
2<project>
3 <publishers>
4 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher plugin="cloudfoundry">
5 <target>https://api.stackato-rkw2.local</target>
6 <organization>AS</organization>
7 <cloudSpace>SimpleSpace</cloudSpace>
8 <credentialsId>123</credentialsId>
9 <selfSigned>true</selfSigned>
10 <resetIfExists>true</resetIfExists>
11 <pluginTimeout>240</pluginTimeout>
12 <appURIs/>
13 <servicesToCreate>
14 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
15 <name>foo-name</name>
16 <type>foo-type</type>
17 <plan>plan1</plan>
18 <resetService>true</resetService>
19 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
20 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
21 <name>bar-name</name>
22 <type>bar-type</type>
23 <plan>plan2</plan>
24 <resetService>false</resetService>
25 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-Service>
26 </servicesToCreate>
27 <manifestChoice>
28 <value>jenkinsConfig</value>
29 <manifestFile>manifest.yml</manifestFile>
30 <appName>cloudfoundry</appName>
31 <memory>1024</memory>
32 <hostname>cloudfoundry</hostname>
33 <instances>5</instances>
34 <timeout>120</timeout>
35 <noRoute>true</noRoute>
36 <appPath>foo</appPath>
37 <buildpack>custom-buildpack</buildpack>
38 <stack>custom-stack</stack>
39 <command>start</command>
40 <domain>cloudfoundry.domain</domain>
41 <envVars>
42 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
43 <key>key</key>
44 <value>value</value>
45 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
46 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
47 <key>key2</key>
48 <value>value2</value>
49 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-EnvironmentVariable>
50 </envVars>
51 <servicesNames>
52 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
53 <name>service-name</name>
54 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
55 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
56 <name>service-name2</name>
57 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher_-ServiceName>
58 </servicesNames>
59 </manifestChoice>
60 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher>
61 </publishers>
62</project>
diff --git a/tests/publishers/fixtures/cloudfoundry-full.yaml b/tests/publishers/fixtures/cloudfoundry-full.yaml
new file mode 100644
index 0000000..9afa811
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-full.yaml
@@ -0,0 +1,39 @@
1publishers:
2 - cloudfoundry:
3 target: https://api.stackato-rkw2.local
4 organization: AS
5 space: SimpleSpace
6 credentials-id: 123
7 self-signed: true
8 reset-app: true
9 timeout: 240
10 create-services:
11 - name: foo-name
12 type: foo-type
13 plan: plan1
14 reset-service: true
15 - name: bar-name
16 type: bar-type
17 plan: plan2
18 reset-service: false
19 value: jenkinsConfig
20 manifest-file: manifest.yml
21 app-name: cloudfoundry
22 memory: 1024
23 host-name: cloudfoundry
24 instances: 5
25 manifest-timeout: 120
26 no-route: true
27 app-path: foo
28 build-pack: custom-buildpack
29 stack: custom-stack
30 command: start
31 domain: cloudfoundry.domain
32 environment-variables:
33 - key: key
34 value: value
35 - key: key2
36 value: value2
37 services-names:
38 - name: service-name
39 - name: service-name2
diff --git a/tests/publishers/fixtures/cloudfoundry-minimal.xml b/tests/publishers/fixtures/cloudfoundry-minimal.xml
new file mode 100644
index 0000000..8a6a51f
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-minimal.xml
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="utf-8"?>
2<project>
3 <publishers>
4 <com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher plugin="cloudfoundry">
5 <target>https://api.stackato-rkw2.local</target>
6 <organization>AS</organization>
7 <cloudSpace>SimpleSpace</cloudSpace>
8 <credentialsId>j89jk213</credentialsId>
9 <selfSigned>false</selfSigned>
10 <resetIfExists>false</resetIfExists>
11 <pluginTimeout>120</pluginTimeout>
12 <appURIs/>
13 <servicesToCreate/>
14 <manifestChoice>
15 <value>manifestFile</value>
16 <manifestFile>manifest.yml</manifestFile>
17 <appName/>
18 <memory>512</memory>
19 <hostname/>
20 <instances>1</instances>
21 <timeout>60</timeout>
22 <noRoute>false</noRoute>
23 <appPath/>
24 <buildpack/>
25 <stack/>
26 <command/>
27 <domain/>
28 </manifestChoice>
29 </com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher>
30 </publishers>
31</project>
diff --git a/tests/publishers/fixtures/cloudfoundry-minimal.yaml b/tests/publishers/fixtures/cloudfoundry-minimal.yaml
new file mode 100644
index 0000000..a96e505
--- /dev/null
+++ b/tests/publishers/fixtures/cloudfoundry-minimal.yaml
@@ -0,0 +1,6 @@
1publishers:
2 - cloudfoundry:
3 target: https://api.stackato-rkw2.local
4 organization: AS
5 space: SimpleSpace
6 credentials-id: j89jk213