Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 1 | import logging |
| 2 | |
| 3 | logger = logging.getLogger(__name__) |
| 4 | |
| 5 | def __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 | |
| 17 | def present(name, hostname, username, frontendurl, auth_key_file, authkey, |
Sergey Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 18 | 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 Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 22 | """ |
| 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 Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 32 | :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 Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 36 | :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 Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 45 | ["CREATED", "CHANGED", "SKIPPED"], |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 46 | { |
| 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 Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 54 | "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 Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 58 | "auth_key_file": auth_key_file, |
| 59 | "authkey": authkey, |
Sergey Otpuschennikov | 107c196 | 2018-06-20 13:45:04 +0400 | [diff] [blame] | 60 | "auth_key_file_password": auth_key_file_password if auth_key_file_password else "" |
Sergey Otpuschennikov | 8399670 | 2017-11-23 17:10:57 +0400 | [diff] [blame] | 61 | }, |
| 62 | "Gerrit server") |