blob: a2b0e957eeaaa818c3aee814a41e1c002960e8d1 [file] [log] [blame]
Sergey Otpuschennikov83996702017-11-23 17:10:57 +04001import logging
2
3logger = logging.getLogger(__name__)
4
5def __virtual__():
6 '''
7 Only load if jenkins_common module exist.
8 '''
9 if 'jenkins_common.call_groovy_script' not in __salt__:
10 return (
11 False,
12 'The jenkins_gerrit state module cannot be loaded: '
13 'jenkins_common not found')
14 return True
15
16
17def present(name, hostname, username, frontendurl, auth_key_file, authkey,
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +040018 port="29418", build_current_patches_only="false",
19 abort_new_patchsets="false", abort_manual_patchsets="false",
20 abort_same_topic="false", auth_key_file_password=None, email="",
21 proxy=""):
Sergey Otpuschennikov83996702017-11-23 17:10:57 +040022 """
23 Jenkins gerrit-trigger state method
24
25 :param name: server name
26 :param host: server hostname
27 :param username: username
28 :param email: trigger email (optional)
29 :param port: server ssh port
30 :param proxy: proxy url (optional)
31 :param frontendurl: server frontend URL
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +040032 :param build_current_patches_only: build current patches only (optional)
33 :abort_new_patchsets: abort new patchsets (optional)
34 :abort_manual_patchsets: abort manual patchsets (optional)
35 :abort_same_topic: abort same topic (optional)
Sergey Otpuschennikov83996702017-11-23 17:10:57 +040036 :param auth_key_file: path to key file
37 :param authkey: ssh key
38 :param auth_key_file_password: password for keyfile (optional)
39 :returns: salt-specified state dict
40 """
41 template = __salt__['jenkins_common.load_template'](
42 'salt://jenkins/files/groovy/gerrit.template',
43 __env__)
44 return __salt__['jenkins_common.api_call'](name, template,
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +040045 ["CREATED", "CHANGED", "SKIPPED"],
Sergey Otpuschennikov83996702017-11-23 17:10:57 +040046 {
47 "name": name,
48 "hostname": hostname,
49 "port": port if port else "29418",
50 "proxy": proxy if proxy else "",
51 "username": username,
52 "email": email if email else "",
53 "frontendurl": frontendurl,
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +040054 "build_current_patches_only": build_current_patches_only if build_current_patches_only else "false",
55 "abort_new_patchsets": abort_new_patchsets if abort_new_patchsets else "false",
56 "abort_manual_patchsets": abort_manual_patchsets if abort_manual_patchsets else "false",
57 "abort_same_topic": abort_same_topic if abort_same_topic else "false",
Sergey Otpuschennikov83996702017-11-23 17:10:57 +040058 "auth_key_file": auth_key_file,
59 "authkey": authkey,
Sergey Otpuschennikov107c1962018-06-20 13:45:04 +040060 "auth_key_file_password": auth_key_file_password if auth_key_file_password else ""
Sergey Otpuschennikov83996702017-11-23 17:10:57 +040061 },
62 "Gerrit server")