summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Hourquebie <jhourque@cisco.com>2015-06-09 14:58:51 +0200
committerThanh Ha <thanh.ha@linuxfoundation.org>2017-10-23 13:34:56 -0400
commit8bcd0d0bd2caf9d28d4f55cba712afb20654b591 (patch)
tree13647a93f6a392d49ce1a9c9ebb817384505cbb8
parent3bb56f745eb4b9d6fc575e09e3ea69c17f21f0b5 (diff)
Add cloudbees folder creation support
Add project folder module. Jenkins folder could be made with project-type: folder This requires Cloudbees folder plugin and python-jenkins folder update (see: https://review.openstack.org/#/c/180185/) Change-Id: I7e1c28c26a69ae6ca736cec88fcb957a716d8fad
Notes
Notes (review): Code-Review+1: Dawid Malinowski <dawidmalina@gmail.com> Code-Review+2: Thanh Ha <zxiiro@gmail.com> Code-Review+2: Kien Ha <kienha9922@gmail.com> Workflow+1: Kien Ha <kienha9922@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 23 Oct 2017 19:12:14 +0000 Reviewed-on: https://review.openstack.org/189697 Project: openstack-infra/jenkins-job-builder Branch: refs/heads/master
-rw-r--r--doc/source/project_folder.rst7
-rw-r--r--jenkins_jobs/modules/project_folder.py57
-rw-r--r--setup.cfg1
-rw-r--r--tests/yamlparser/fixtures/project_folder_template001.xml20
-rw-r--r--tests/yamlparser/fixtures/project_folder_template001.yaml3
-rw-r--r--tests/yamlparser/fixtures/project_folder_template002.xml20
-rw-r--r--tests/yamlparser/fixtures/project_folder_template002.yaml8
7 files changed, 116 insertions, 0 deletions
diff --git a/doc/source/project_folder.rst b/doc/source/project_folder.rst
new file mode 100644
index 0000000..1d5b70a
--- /dev/null
+++ b/doc/source/project_folder.rst
@@ -0,0 +1,7 @@
1.. _project_folder:
2
3Folder Project
4=================
5
6.. automodule:: project_folder
7 :members:
diff --git a/jenkins_jobs/modules/project_folder.py b/jenkins_jobs/modules/project_folder.py
new file mode 100644
index 0000000..ac6e6bd
--- /dev/null
+++ b/jenkins_jobs/modules/project_folder.py
@@ -0,0 +1,57 @@
1# -*- coding: utf-8 -*-
2# Copyright (C) 2015 Cisco Systems, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16
17"""
18The folder Project module handles creating Jenkins folder projects.
19You may specify ``folder`` in the ``project-type`` attribute of
20the :ref:`Job` definition.
21
22Requires the Jenkins :jenkins-wiki:`CloudBees Folder Plugin
23<CloudBees+Folder+Plugin>`.
24
25Job example:
26
27 .. literalinclude::
28 /../../tests/yamlparser/fixtures/project_folder_template001.yaml
29
30Job template example:
31
32 .. literalinclude::
33 /../../tests/yamlparser/fixtures/project_folder_template002.yaml
34
35"""
36
37import xml.etree.ElementTree as XML
38import jenkins_jobs.modules.base
39
40
41class Folder(jenkins_jobs.modules.base.Base):
42 sequence = 0
43
44 def root_xml(self, data):
45 xml_parent = XML.Element('com.cloudbees.hudson.plugins.folder.Folder',
46 plugin="cloudbees-folder")
47 XML.SubElement(xml_parent, 'actions')
48 attributes = {"class": "com.cloudbees.hudson.plugins.folder."
49 "icons.StockFolderIcon"}
50 XML.SubElement(xml_parent, 'icon', attrib=attributes)
51 XML.SubElement(xml_parent, 'views')
52 attributes = {"class": "hudson.views.DefaultViewsTabBar"}
53 XML.SubElement(xml_parent, 'viewsTabBar', attrib=attributes)
54 XML.SubElement(xml_parent, 'primaryView').text = 'All'
55 XML.SubElement(xml_parent, 'healthMetrics')
56
57 return xml_parent
diff --git a/setup.cfg b/setup.cfg
index 1d5a34a..77edb7e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -44,6 +44,7 @@ jjb.cli.subcommands =
44jenkins_jobs.projects = 44jenkins_jobs.projects =
45 externaljob=jenkins_jobs.modules.project_externaljob:ExternalJob 45 externaljob=jenkins_jobs.modules.project_externaljob:ExternalJob
46 flow=jenkins_jobs.modules.project_flow:Flow 46 flow=jenkins_jobs.modules.project_flow:Flow
47 folder=jenkins_jobs.modules.project_folder:Folder
47 freestyle=jenkins_jobs.modules.project_freestyle:Freestyle 48 freestyle=jenkins_jobs.modules.project_freestyle:Freestyle
48 matrix=jenkins_jobs.modules.project_matrix:Matrix 49 matrix=jenkins_jobs.modules.project_matrix:Matrix
49 maven=jenkins_jobs.modules.project_maven:Maven 50 maven=jenkins_jobs.modules.project_maven:Maven
diff --git a/tests/yamlparser/fixtures/project_folder_template001.xml b/tests/yamlparser/fixtures/project_folder_template001.xml
new file mode 100644
index 0000000..38cd68d
--- /dev/null
+++ b/tests/yamlparser/fixtures/project_folder_template001.xml
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<com.cloudbees.hudson.plugins.folder.Folder plugin="cloudbees-folder">
3 <actions/>
4 <icon class="com.cloudbees.hudson.plugins.folder.icons.StockFolderIcon"/>
5 <views/>
6 <viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
7 <primaryView>All</primaryView>
8 <healthMetrics/>
9 <actions/>
10 <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
11 <keepDependencies>false</keepDependencies>
12 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
13 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
14 <concurrentBuild>false</concurrentBuild>
15 <canRoam>true</canRoam>
16 <properties/>
17 <scm class="hudson.scm.NullSCM"/>
18 <publishers/>
19 <buildWrappers/>
20</com.cloudbees.hudson.plugins.folder.Folder>
diff --git a/tests/yamlparser/fixtures/project_folder_template001.yaml b/tests/yamlparser/fixtures/project_folder_template001.yaml
new file mode 100644
index 0000000..0a49949
--- /dev/null
+++ b/tests/yamlparser/fixtures/project_folder_template001.yaml
@@ -0,0 +1,3 @@
1- job:
2 name: folder_test
3 project-type: folder
diff --git a/tests/yamlparser/fixtures/project_folder_template002.xml b/tests/yamlparser/fixtures/project_folder_template002.xml
new file mode 100644
index 0000000..38cd68d
--- /dev/null
+++ b/tests/yamlparser/fixtures/project_folder_template002.xml
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<com.cloudbees.hudson.plugins.folder.Folder plugin="cloudbees-folder">
3 <actions/>
4 <icon class="com.cloudbees.hudson.plugins.folder.icons.StockFolderIcon"/>
5 <views/>
6 <viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
7 <primaryView>All</primaryView>
8 <healthMetrics/>
9 <actions/>
10 <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
11 <keepDependencies>false</keepDependencies>
12 <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
13 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
14 <concurrentBuild>false</concurrentBuild>
15 <canRoam>true</canRoam>
16 <properties/>
17 <scm class="hudson.scm.NullSCM"/>
18 <publishers/>
19 <buildWrappers/>
20</com.cloudbees.hudson.plugins.folder.Folder>
diff --git a/tests/yamlparser/fixtures/project_folder_template002.yaml b/tests/yamlparser/fixtures/project_folder_template002.yaml
new file mode 100644
index 0000000..4af049c
--- /dev/null
+++ b/tests/yamlparser/fixtures/project_folder_template002.yaml
@@ -0,0 +1,8 @@
1- job-template:
2 name: 'folder-{name}'
3 project-type: folder
4
5- project:
6 name: test
7 jobs:
8 - 'folder-{name}'