def gitlab(registry, xml_parent, data):
 def _add_xml(elem, name, value):
  XML.SubElement(elem, name).text = value
 gitlab = XML.SubElement(xml_parent, 'com.dabsquared.gitlabjenkins.GitLabPushTrigger')
 plugin_info = registry.get_plugin_info('GitLab Plugin')
 plugin_ver = pkg_resources.parse_version(plugin_info.get('version', '0'))
 valid_merge_request = ['never', 'source', 'both']
 if (plugin_ver >= pkg_resources.parse_version('1.1.26')):
  mapping = [('trigger-open-merge-request-push', 'triggerOpenMergeRequestOnPush', 'never', valid_merge_request)]
  convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
 else:
  mapping = [('trigger-open-merge-request-push', 'triggerOpenMergeRequestOnPush', True)]
  convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
 if (plugin_ver == pkg_resources.parse_version('1.1.29')):
  if (data.get('branch-filter-type', '') == 'All'):
   data['branch-filter-type'] = ''
  valid_filters = ['', 'NameBasedFilter', 'RegexBasedFilter']
  mapping = [('branch-filter-type', 'branchFilterName', '', valid_filters)]
  convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
 else:
  valid_filters = ['All', 'NameBasedFilter', 'RegexBasedFilter']
  mapping = [('branch-filter-type', 'branchFilterType', 'All', valid_filters)]
  convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
 XML.SubElement(gitlab, 'spec').text = ''
 mapping = [('trigger-push', 'triggerOnPush', True), ('trigger-merge-request', 'triggerOnMergeRequest', True), ('trigger-note', 'triggerOnNoteRequest', True), ('note-regex', 'noteRegex', 'Jenkins please retry a build'), ('ci-skip', 'ciSkip', True), ('wip-skip', 'skipWorkInProgressMergeRequest', True), ('set-build-description', 'setBuildDescription', True), ('add-note-merge-request', 'addNoteOnMergeRequest', True), ('add-vote-merge-request', 'addVoteOnMergeRequest', True), ('accept-merge-request-on-success', 'acceptMergeRequestOnSuccess', False), ('add-ci-message', 'addCiMessage', False), ('allow-all-branches', 'allowAllBranches', False), ('target-branch-regex', 'targetBranchRegex', '')]
 list_mapping = (('include-branches', 'includeBranchesSpec', []), ('exclude-branches', 'excludeBranchesSpec', []))
 convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
 for (yaml_name, xml_name, default_val) in list_mapping:
  value = ', '.join(data.get(yaml_name, default_val))
  _add_xml(gitlab, xml_name, value)

def gitlab ( registry , xml_parent , data ) : def _add_xml ( elem , name , value ) : XML . SubElement ( elem , name ) . text = value gitlab = XML . SubElement ( xml_parent , 'com.dabsquared.gitlabjenkins.GitLabPushTrigger' ) plugin_info = registry . get_plugin_info ( 'GitLab Plugin' ) plugin_ver = pkg_resources . parse_version ( plugin_info . get ( 'version' , '0' ) ) valid_merge_request = [ 'never' , 'source' , 'both' ] if ( plugin_ver >= pkg_resources . parse_version ( '1.1.26' ) ) : mapping = [ ( 'trigger-open-merge-request-push' , 'triggerOpenMergeRequestOnPush' , 'never' , valid_merge_request ) ] convert_mapping_to_xml ( gitlab , data , mapping , fail_required = True ) else : mapping = [ ( 'trigger-open-merge-request-push' , 'triggerOpenMergeRequestOnPush' , True ) ] convert_mapping_to_xml ( gitlab , data , mapping , fail_required = True ) if ( plugin_ver == pkg_resources . parse_version ( '1.1.29' ) ) : if ( data . get ( 'branch-filter-type' , '' ) == 'All' ) : data [ 'branch-filter-type' ] = '' valid_filters = [ '' , 'NameBasedFilter' , 'RegexBasedFilter' ] mapping = [ ( 'branch-filter-type' , 'branchFilterName' , '' , valid_filters ) ] convert_mapping_to_xml ( gitlab , data , mapping , fail_required = True ) else : valid_filters = [ 'All' , 'NameBasedFilter' , 'RegexBasedFilter' ] mapping = [ ( 'branch-filter-type' , 'branchFilterType' , 'All' , valid_filters ) ] convert_mapping_to_xml ( gitlab , data , mapping , fail_required = True ) XML . SubElement ( gitlab , 'spec' ) . text = '' mapping = [ ( 'trigger-push' , 'triggerOnPush' , True ) , ( 'trigger-merge-request' , 'triggerOnMergeRequest' , True ) , ( 'trigger-note' , 'triggerOnNoteRequest' , True ) , ( 'note-regex' , 'noteRegex' , 'Jenkins please retry a build' ) , ( 'ci-skip' , 'ciSkip' , True ) , ( 'wip-skip' , 'skipWorkInProgressMergeRequest' , True ) , ( 'set-build-description' , 'setBuildDescription' , True ) , ( 'add-note-merge-request' , 'addNoteOnMergeRequest' , True ) , ( 'add-vote-merge-request' , 'addVoteOnMergeRequest' , True ) , ( 'accept-merge-request-on-success' , 'acceptMergeRequestOnSuccess' , False ) , ( 'add-ci-message' , 'addCiMessage' , False ) , ( 'allow-all-branches' , 'allowAllBranches' , False ) , ( 'target-branch-regex' , 'targetBranchRegex' , '' ) ] list_mapping = ( ( 'include-branches' , 'includeBranchesSpec' , [ ] ) , ( 'exclude-branches' , 'excludeBranchesSpec' , [ ] ) ) convert_mapping_to_xml ( gitlab , data , mapping , fail_required = True ) for ( yaml_name , xml_name , default_val ) in list_mapping : value = ', ' . join ( data . get ( yaml_name , default_val ) ) _add_xml ( gitlab , xml_name , value )
yaml: gitlab sets the gitlab connection for the project .