Debian Codegraph @

jenkins_jobs/modules/project_folder.py

raw
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 """
18 The folder Project module handles creating Jenkins folder projects.
19 You may specify ``folder`` in the ``project-type`` attribute of
20 the :ref:`Job` definition.
21
22 Requires the Jenkins :jenkins-plugins:`CloudBees Folders Plugin
23 <cloudbees-folder>`.
24
25 Job example:
26
27 .. literalinclude::
28 /../../tests/yamlparser/job_fixtures/project_folder_template001.yaml
29
30 Job template example:
31
32 .. literalinclude::
33 /../../tests/yamlparser/job_fixtures/project_folder_template002.yaml
34
35 """
36
37 import xml.etree.ElementTree as XML
38 import jenkins_jobs.modules.base
39 from jenkins_jobs.modules.helpers import convert_mapping_to_xml
40
41
42 class Folder(jenkins_jobs.modules.base.Base):
43 sequence = 0
44
45 def root_xml(self, data):
46 xml_parent = XML.Element(
47 "com.cloudbees.hudson.plugins.folder.Folder", plugin="cloudbees-folder"
48 )
49 attributes = {
50 "class": "com.cloudbees.hudson.plugins.folder." "icons.StockFolderIcon"
51 }
52 XML.SubElement(xml_parent, "icon", attrib=attributes)
53 XML.SubElement(xml_parent, "views")
54 attributes = {"class": "hudson.views.DefaultViewsTabBar"}
55 XML.SubElement(xml_parent, "viewsTabBar", attrib=attributes)
56
57 mappings = [("", "primaryView", "All"), ("", "healthMetrics", "")]
58 convert_mapping_to_xml(xml_parent, data, mappings, True)
59
60 return xml_parent