blob: 739b248e431684f9323bbe2b7578bcd7e758bae1 [file] [log] [blame]
Dmitry Burmistrov429b8ec2018-04-25 17:13:48 +04001import json
2import logging
3
4logger = logging.getLogger(__name__)
5
6def __virtual__():
7 '''
8 Only load if jenkins_common module exist.
9 '''
10 if 'jenkins_common.call_groovy_script' not in __salt__:
11 return (
12 False,
13 'The jenkins_jira state module cannot be loaded: '
14 'jenkins_common not found')
15 return True
16
17def present (name, sites, **kwargs):
18 """
19 Jenkins Jira instance state method
20
21 :param name: ID name
22 :param sites:Jira sites dict
23 :
24 :sites[name] params:
25 :param link_url: root URL of JIRA installation for "normal" access
26 :param http_auth: connect to JIRA using HTTP Basic Authentication
27 :param use_wiki_notation: enable if JIRA supports Wiki notation
28 :param record_scm: record scm changes in JIRAA
29 :param disable_changelog: do not create JIRA hyperlinks in the changeset
30 :param issue_pattern: custom pattern to search for JIRA issue ids
31 :param any_build_result: update issues on any build result
32 :param user: JIRA user name
33 :param password: JIRA user password
34 :param conn_timeout: connection timeout for JIRA REST API calls
35 :param visible_for_group: allow to read comments for JIRA group
36 :param visible_for_project: allow to read comments for JIRA project
37 :param timestamps: enable SCM change date and time entries
38 :param timestamp_format: timestamp format
39 :
40 :returns: salt-specified state dict
41 """
42
43 template = __salt__['jenkins_common.load_template'](
44 'salt://jenkins/files/groovy/jira.template',
45 __env__)
46 return __salt__['jenkins_common.api_call'](name, template,
47 ["CREATED", "EXISTS"],
48 {
49 'sites': json.dumps(sites),
50 'absent': False
51 },
52 'JIRA server')
53
54def absent(name):
55 """
56 Jenkins Jira instance absence state method
57
58 :param name: ID name
59 :returns: salt-specified state dict
60 """
61 template = __salt__['jenkins_common.load_template'](
62 'salt://jenkins/files/groovy/jira.template',
63 __env__)
64 return __salt__['jenkins_common.api_call'](name, template,
65 ["REMOVED", "NOT PRESENT"],
66 {
67 'sites': '{}',
68 'absent': True
69 },
70 'JIRA server')
71