예제 #1
0
def ghprbtrigger(top, parent):
    ghpr = {}
    for child in top:
        if child.tag == 'spec' or child.tag == 'cron':
            ghpr['cron'] = child.text
        elif child.tag == 'adminlist' and child.text:
            ghpr['admin-list'] = child.text.strip().split('\n')
        elif child.tag == 'allowMembersOfWhitelistedOrgsAsAdmin':
            ghpr['allow-whitelist-orgs-as-admins'] = get_bool(child.text)
        elif child.tag == 'whitelist' and child.text is not None:
            ghpr['white-list'] = child.text.strip().split('\n')
        elif child.tag == 'orgslist' and child.text is not None:
            ghpr['org-list'] = child.text.strip().split('\n')
        elif child.tag == 'buildDescTemplate':
            ghpr['build-desc-template'] = child.text
        elif child.tag == 'triggerPhrase':
            ghpr['trigger-phrase'] = child.text
        elif child.tag == 'onlyTriggerPhrase':
            ghpr['only-trigger-phrase'] = get_bool(child.text)
        elif child.tag == 'useGitHubHooks':
            ghpr['github-hooks'] = get_bool(child.text)
        elif child.tag == 'permitAll':
            ghpr['permit-all'] = get_bool(child.text)
        elif child.tag == 'autoCloseFailedPullRequests':
            ghpr['auto-close-on-fail'] = get_bool(child.text)
        elif child.tag == 'whiteListTargetBranches':
            ghpr['white-list-target-branches'] = []
            for branch in child:
                if branch[0].text is not None:
                    ghpr['white-list-target-branches'].append(
                        branch[0].text.strip())
        elif child.tag == 'gitHubAuthId':
            ghpr['auth-id'] = child.text

    parent.append({'github-pull-request': ghpr})
예제 #2
0
def __gerrit_process_trigger_on_events(child):
    trigger_on = []
    sonyericsson_prefix = "com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events."
    for event in child:
        if event.tag == sonyericsson_prefix + "PluginChangeAbandonedEvent":
            trigger_on.append("change-abandoned-event")
        elif event.tag == sonyericsson_prefix + "PluginChangeMergedEvent":
            trigger_on.append("change-merged-event")
        elif event.tag == sonyericsson_prefix + "PluginChangeRestoredEvent":
            trigger_on.append("change-restored-event")
        elif event.tag == sonyericsson_prefix + "PluginCommentAddedEvent":
            comment_added_event = {}
            for element in event:
                if element.tag == "verdictCategory":
                    comment_added_event["approval-category"] = element.text
                elif element.tag == "commentAddedTriggerApprovalValue":
                    comment_added_event["approval-value"] = element.text
            trigger_on.append({"comment-added-event": comment_added_event})
        elif event.tag == sonyericsson_prefix + "PluginCommentAddedContainsEvent":
            trigger_on.append({
                "comment-added-contains-event": {
                    "comment-contains-value": event[0].text
                }
            })
        elif event.tag == sonyericsson_prefix + "PluginDraftPublishedEvent":
            trigger_on.append("draft-published-event")
        elif event.tag == sonyericsson_prefix + "PluginPatchsetCreatedEvent":
            patchset_created_event = {}
            for attribute in event:
                if attribute.tag == "excludeDrafts":
                    patchset_created_event["exclude-drafts"] = get_bool(
                        attribute.text)
                elif attribute.tag == "excludeTrivialRebase":
                    patchset_created_event[
                        "exclude-trivial-rebase"] = get_bool(attribute.text)
                elif attribute.tag == "excludeNoCodeChange":
                    patchset_created_event[
                        "exclude-no-code-change"] = get_bool(attribute.text)
                elif attribute.tag == "excludePrivateState":
                    patchset_created_event["exclude-private"] = get_bool(
                        attribute.text)
                elif attribute.tag == "excludeWipState":
                    patchset_created_event["exclude-wip"] = get_bool(
                        attribute.text)
            trigger_on.append(
                {"patchset-created-event": patchset_created_event})
        elif event.tag == sonyericsson_prefix + "PluginPrivateStateChangedEvent":
            trigger_on.append("private-state-changed-event")
        elif event.tag == sonyericsson_prefix + "PluginRefUpdatedEvent":
            trigger_on.append("ref-updated-event")
        elif event.tag == sonyericsson_prefix + "PluginTopicChangedEvent":
            trigger_on.append("topic-changed-event")
        elif event.tag == sonyericsson_prefix + "PluginWipStateChangedEvent":
            trigger_on.append("wip-state-changed-event")
    return trigger_on
def wscleanup(top, parent):
    cleanup = {'include': [], 'exclude': [], 'clean-if': []}
    for cleanupel in top:
        if cleanupel.tag == 'patterns':
            for pattern in cleanupel:
                pattern_glob = None
                pattern_type = None
                for patternel in pattern:
                    if patternel.tag == 'pattern':
                        pattern_glob = patternel.text
                    elif patternel.tag == 'type':
                        pattern_type = patternel.text
                cleanup[pattern_type.lower()].append(pattern_glob)
        elif cleanupel.tag == 'deleteDirs':
            cleanup['dirmatch'] = get_bool(cleanupel.text)
        elif cleanupel.tag == 'cleanWhenSuccess':
            cleanup['clean-if'].append({'success': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenUnstable':
            cleanup['clean-if'].append({'unstable': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenFailure':
            cleanup['clean-if'].append({'failure': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenNotBuilt':
            cleanup['clean-if'].append({'not-built': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenAborted':
            cleanup['clean-if'].append({'aborted': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'notFailBuild':
            cleanup['fail-build'] = not get_bool(cleanupel.text)
        elif cleanupel.tag == 'cleanupMatrixParent':
            cleanup['clean-parent'] = get_bool(cleanupel.text)
    parent.append({'workspace-cleanup': cleanup})
def wscleanup(top, parent):
    cleanup = {'include': [], 'exclude': [], 'clean-if': []}
    for cleanupel in top:
        if cleanupel.tag == 'patterns':
            for pattern in cleanupel:
                pattern_glob = None
                pattern_type = None
                for patternel in pattern:
                    if patternel.tag == 'pattern':
                        pattern_glob = patternel.text
                    elif patternel.tag == 'type':
                        pattern_type = patternel.text
                cleanup[pattern_type.lower()].append(pattern_glob)
        elif cleanupel.tag == 'deleteDirs':
            cleanup['dirmatch'] = get_bool(cleanupel.text)
        elif cleanupel.tag == 'cleanWhenSuccess':
            cleanup['clean-if'].append({'success': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenUnstable':
            cleanup['clean-if'].append({'unstable': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenFailure':
            cleanup['clean-if'].append({'failure': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenNotBuilt':
            cleanup['clean-if'].append({'not-built': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'cleanWhenAborted':
            cleanup['clean-if'].append({'aborted': get_bool(cleanupel.text)})
        elif cleanupel.tag == 'notFailBuild':
            cleanup['fail-build'] = not get_bool(cleanupel.text)
        elif cleanupel.tag == 'cleanupMatrixParent':
            cleanup['clean-parent'] = get_bool(cleanupel.text)
    parent.append({'workspace-cleanup': cleanup})
예제 #5
0
def envinjectjobproperty(top, parent):
    env_info = {}
    for child in top:
        if child.tag == 'info':
            for grandchild in child:
                if grandchild.tag == 'loadFilesFromMaster':
                    env_info['load-from-master'] = get_bool(grandchild.text)
                elif grandchild.tag == 'groovyScriptContent':
                    if grandchild.text:
                        env_info['groovy-content'] = grandchild.text
                elif grandchild.tag == 'secureGroovyScript':
                    for ggchild in grandchild:
                        if ggchild.tag == 'script':
                            if ggchild.text:
                                env_info['groovy-content'] = ggchild.text
                        elif ggchild.tag == 'sandbox':
                            # No support in jjb for this, fail quietly for
                            # this one
                            pass
                        else:
                            raise NotImplementedError("cannot handle XML %s" %
                                                      ggchild.tag)
                elif grandchild.tag == 'scriptContent':
                    if grandchild.text:
                        env_info['script-content'] = grandchild.text
                elif grandchild.tag == 'scriptFilePath':
                    if grandchild.text:
                        env_info['script-file'] = grandchild.text
                elif grandchild.tag == 'propertiesContent':
                    if grandchild.text:
                        env_info['properties-content'] = grandchild.text
                elif grandchild.tag == 'propertiesFilePath':
                    if grandchild.text:
                        env_info['properties-file'] = grandchild.text
                else:
                    raise NotImplementedError("cannot handle XML %s" %
                                              grandchild.tag)
        elif child.tag == 'on':
            env_info['enabled'] = get_bool(child.text)
        elif child.tag == 'keepJenkinsSystemVariables':
            env_info['keep-system-variables'] = get_bool(child.text)
        elif child.tag == 'keepBuildVariables':
            env_info['keep-build-variables'] = get_bool(child.text)
        elif child.tag == 'overrideBuildParameters':
            env_info['override-build-parameters'] = get_bool(child.text)
        else:
            raise NotImplementedError("cannot handle XML %s" % child.tag)

    parent.append({'inject': env_info})
예제 #6
0
def slacknotifier(top, parent):
    slacknotifier = {}
    notifications = {
        "startNotification": "notify-start",
        "notifySuccess": "notify-success",
        "notifyAborted": "notify-aborted",
        "notifyNotBuilt": "notify-not-built",
        "notifyUnstable": "notify-unstable",
        "notifyFailure": "notify-failure",
        "notifyBackToNormal": "notify-back-to-normal",
        "notifyRegression": "notify-regression",
        "notifyRepeatedFailure": "notify-repeated-failure"
    }
    for child in top:
        if child.tag == 'teamDomain':
            if child.text:
                slacknotifier['team-domain'] = child.text
        elif child.tag == 'authToken':
            if child.text:
                slacknotifier['auth-token'] = child.text
        elif child.tag == 'authTokenCredentialId':
            if child.text:
                slacknotifier['auth-token-credential-id'] = child.text
        elif child.tag == 'buildServerUrl':
            slacknotifier['build-server-url'] = child.text
        elif child.tag == 'room':
            slacknotifier['room'] = child.text
        elif child.tag in notifications:
            slacknotifier[notifications[child.tag]] = get_bool(child.text)
        elif child.tag == 'includeTestSummary':
            slacknotifier['include-test-summary'] = get_bool(child.text)
        elif child.tag == 'includeFailedTests':
            slacknotifier['include-failed-tests'] = get_bool(child.text)
        elif child.tag == 'commitInfoChoice':
            slacknotifier['commit-info-choice'] = child.text
        elif child.tag == 'includeCustomMessage':
            slacknotifier['include-custom-message'] = get_bool(child.text)
        elif child.tag == 'customMessage':
            if child.text:
                slacknotifier['custom-message'] = child.text
        elif child.tag == 'botUser':
            slacknotifier['bot-user'] = get_bool(child.text)
        elif child.tag == 'baseUrl':
            if child.text:
                slacknotifier['base-url'] = child.text
        else:
            raise NotImplementedError("cannot handle " "XML %s" % child.tag)
    parent.append({'slack': slacknotifier})
예제 #7
0
def definition(top, parent):
    reg = Registry()
    handlers = Handlers(reg)
    # Create register
    reg = Registry()

    # sub-level "definition" data
    definition = {}
    if 'class' in top.attrib:  # Pipeline script
        if top.attrib[
                'class'] == 'org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition':
            #  Using pipeline-scm (getting jenkinsfile from repo)
            parent.append(['pipeline-scm', definition])
        elif top.attrib[
                'class'] == 'org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition':
            # Using DSL (passing raw pipeline script)
            for child in top.getchildren():
                if child.tag == 'script':
                    parent.append(['dsl', child.text])
                elif child.tag == 'sandbox':
                    parent.append(['sandbox', get_bool(child.text)])
            # Don't pass anything to handlers.gen_yml, handled it here
            top = ''
    else:
        parent.append(['definition', definition])
    reg = Registry()
    handlers = Handlers(reg)
    handlers.gen_yml(definition, top)
예제 #8
0
def artifactarchiver(top, parent):
    archive = {}
    for element in top:
        if element.tag == 'artifacts':
            archive['artifacts'] = element.text
        elif element.tag == 'allowEmptyArchive':
            archive['allow-empty'] = get_bool(element.text)
        elif element.tag == 'fingerprint':
            archive['fingerprint'] = get_bool(element.text)
        elif element.tag == 'onlyIfSuccessful':
            # only-if-success first available in JJB 1.3.0
            archive['only-if-success'] = get_bool(element.text)
        elif element.tag == 'defaultExcludes':
            # default-excludes is not yet available in JJB master
            archive['default-excludes'] = get_bool(element.text)
        elif element.tag == 'latestOnly':
            archive['latest-only'] = get_bool(element.text)
        elif element.tag == 'caseSensitive':
            archive['case-sensitive'] = get_bool(element.text)
        elif element.tag == 'excludes':
            archive['excludes'] = element.text
        else:
            raise NotImplementedError("cannot handle " "XML %s" % element.tag)

    parent.append({'archive': archive})
예제 #9
0
def executionstrategy(top, parent):
    strategy = {}
    for child in top:

        if child.tag == 'runSequentially':
            strategy['sequential'] = get_bool(top.text)
        elif child.tag == 'sorter':
            # Is there anything but NOOP?
            pass
        else:
            raise NotImplementedError("cannot handle XML %s" % child.tag)

    parent.append(['execution-strategy', strategy])
예제 #10
0
def __gerrit_process_gerrit_projects(child):
    projects = []
    for gerrit_project in child:
        project = {}
        for attribute in gerrit_project:
            if attribute.tag == "compareType":
                project["project-compare-type"] = attribute.text
            elif attribute.tag == "pattern":
                project["project-pattern"] = attribute.text
            elif attribute.tag == "branches":
                branches = []
                for branch_type in attribute:
                    if branch_type.tag == \
                            "com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch":
                        branch = {}
                        for branch_attribute in attribute[0]:
                            if branch_attribute.tag == "compareType":
                                branch[
                                    "branch-compare-type"] = branch_attribute.text
                            elif branch_attribute.tag == "pattern":
                                branch[
                                    "branch-pattern"] = branch_attribute.text
                            else:
                                raise NotImplementedError(
                                    "Not implemented branch attribute: ",
                                    branch_attribute.tag)
                        branches.append(branch)
                    else:
                        raise NotImplementedError(
                            "Not implemented branch type: ", branch_type.tag)
                project["branches"] = branches

            elif attribute.tag == "disableStrictForbiddenFileVerification":
                project[
                    "disable-strict-forbidden-file-verification"] = get_bool(
                        attribute.text)
            elif attribute.tag == "filePaths":
                file_paths = __gerrit_process_file_paths(attribute)
                project["file-paths"] = file_paths
            elif attribute.tag == "forbiddenFilePaths":
                forbidden_file_paths = __gerrit_process_file_paths(attribute)
                project["forbidden-file-paths"] = forbidden_file_paths
            elif attribute.tag == "topics":
                topics = __gerrit_process_file_paths(attribute)
                project["topics"] = topics
            else:
                raise NotImplementedError("Not implemented attribute: ",
                                          attribute.tag)

        projects.append(project)
    return projects
예제 #11
0
def buildblockerproperty(top, parent):
    build_blocker_property = {}
    for child in top:
        if child.tag == "useBuildBlocker":
            build_blocker_property["use-build-blocker"] = get_bool(child.text)
        elif child.tag == "blockLevel":
            build_blocker_property["block-level"] = child.text
        elif child.tag == "scanQueueFor":
            build_blocker_property["queue-scanning"] = child.text
        elif child.tag == "blockingJobs":
            blocking_jobs = []
            if child.text is not None:
                blocking_jobs = [name.strip() for name in child.text.split('\n')]
            build_blocker_property["blocking-jobs"] = blocking_jobs
    parent.append({'build-blocker': build_blocker_property})
def postbuildtask(top, parent):
    post_tasks = []
    for pt in top[0]:
        post_task = {}
        for ptel in pt:
            if ptel.tag == 'logTexts':
                matches = []
                for logtext in ptel:
                    match = {}
                    for logtextel in logtext:
                        if logtextel.tag == 'logText':
                            match['log-text'] = logtextel.text
                        elif logtextel.tag == 'operator':
                            match['operator'] = logtextel.text
                    matches.append(match)
                post_task['matches'] = matches
            elif ptel.tag == 'EscalateStatus':
                post_task['escalate-status'] = get_bool(ptel.text)
            elif ptel.tag == 'RunIfJobSuccessful':
                post_task['run-if-job-successful'] = get_bool(ptel.text)
            elif ptel.tag == 'script':
                post_task['script'] = ptel.text
        post_tasks.append(post_task)
    parent.append({'post-tasks': post_tasks})
def postbuildtask(top, parent):
    post_tasks = []
    for pt in top[0]:
        post_task = {}
        for ptel in pt:
            if ptel.tag == 'logTexts':
                matches = []
                for logtext in ptel:
                    match = {}
                    for logtextel in logtext:
                        if logtextel.tag == 'logText':
                            match['log-text'] = logtextel.text
                        elif logtextel.tag == 'operator':
                            match['operator'] = logtextel.text
                    matches.append(match)
                post_task['matches'] = matches
            elif ptel.tag == 'EscalateStatus':
                post_task['escalate-status'] = get_bool(ptel.text)
            elif ptel.tag == 'RunIfJobSuccessful':
                post_task['run-if-job-successful'] = get_bool(ptel.text)
            elif ptel.tag == 'script':
                post_task['script'] = ptel.text
        post_tasks.append(post_task)
    parent.append({'post-tasks': post_tasks})
def throttlejobproperty(top, parent):
    throttle = {}
    for child in top:
        if child.tag == 'maxConcurrentPerNode':
            throttle['max-per-node'] = child.text
        elif child.tag == 'maxConcurrentTotal':
            throttle['max-total'] = child.text
        elif child.tag == 'throttleOption':
            throttle['option'] = child.text
        elif child.tag == 'throttleEnabled':
            throttle['enabled'] = get_bool(child.text)
        elif child.tag == 'categories':
            throttle['categories'] = []
        elif child.tag == 'configVersion':
            pass  # assigned by jjb
        else:
            raise NotImplementedError("cannot handle XML %s" % child.tag)

    parent.append({'throttle': throttle})
예제 #15
0
def throttlejobproperty(top, parent):
    throttle = {}
    for child in top:
        if child.tag == 'maxConcurrentPerNode':
            throttle['max-per-node'] = child.text
        elif child.tag == 'maxConcurrentTotal':
            throttle['max-total'] = child.text
        elif child.tag == 'throttleOption':
            throttle['option'] = child.text
        elif child.tag == 'throttleEnabled':
            throttle['enabled'] = get_bool(child.text)
        elif child.tag == 'categories':
            throttle['categories'] = []
        elif child.tag == 'configVersion':
            pass  # assigned by jjb
        else:
            raise NotImplementedError("cannot handle XML %s" % child.tag)

    parent.append({'throttle': throttle})
예제 #16
0
    def gen_yml(self, yml_parent, data):
        view = {'view-type': 'list'}

        for child in data:
            if child.tag == 'name':
                continue  # Name already declared in other section of YAML
            elif child.tag == 'description':
                view['description'] = child.text
            elif child.tag == 'filterExecutors':
                view['filter-executors'] = get_bool(child.text)
            elif child.tag == 'filterQueue':
                view['filter-queue'] = get_bool(child.text)
            elif child.tag == 'jobFilters':
                filters = {}
                for gchild in child:
                    # most-recent filter
                    if gchild.tag == 'hudson.views.MostRecentJobsFilter':
                        recent = {}
                        filters['most-recent'] = recent
                        for ggchild in gchild:
                            if ggchild.tag == 'maxToInclude':
                                recent['max-to-include'] = int(ggchild.text)
                            elif ggchild.tag == 'checkStartTime':
                                recent['check-start-time'] = get_bool(ggchild.text)
                            else:
                                raise NotImplementedError("cannot handle XML %s" % ggchild.tag)
                    # build-duration filter
                    elif gchild.tag == 'hudson.views.BuildDurationFilter':
                        builddur = {}
                        filters['build-duration'] = builddur
                        for ggchild in gchild:
                            if ggchild.tag == 'includeExcludeTypeString':
                                builddur['match-type'] = ggchild.text
                            elif ggchild.tag == 'buildCountTypeString':
                                builddur['build-duration-type'] = ggchild.text
                            elif ggchild.tag == 'amountTypeString':
                                builddur['amount-type'] = ggchild.text
                            elif ggchild.tag == 'amount':
                                builddur['amount'] = int(ggchild.text)
                            elif ggchild.tag == 'lessThan':
                                builddur['less-than'] = get_bool(ggchild.text)
                            elif ggchild.tag == 'buildDurationMinutes':
                                builddur['build-duration-minutes'] = int(ggchild.text)
                            else:
                                raise NotImplementedError("cannot handle XML %s" % ggchild.tag)
                    # build-trend filter
                    elif gchild.tag == 'hudson.views.BuildTrendFilter':
                        trend = {}
                        filters['build-trend'] = trend
                        for ggchild in gchild:
                            if ggchild.tag == 'includeExcludeTypeString':
                                trend['match-type'] = ggchild.text
                            elif ggchild.tag == 'buildCountTypeString':
                                trend['build-trend-type'] = ggchild.text
                            elif ggchild.tag == 'amountTypeString':
                                trend['amount-type'] = ggchild.text
                            elif ggchild.tag == 'amount':
                                trend['amount'] = int(ggchild.text)
                            elif ggchild.tag == 'statusTypeString':
                                trend['status'] = ggchild.text
                            else:
                                raise NotImplementedError("cannot handle XML %s" % ggchild.tag)
                    # job-status filter
                    elif gchild.tag == 'hudson.views.JobStatusFilter':
                        status = {}
                        filters['job-status'] = status
                        for ggchild in gchild:
                            if ggchild.tag == 'includeExcludeTypeString':
                                status['match-type'] = ggchild.text
                            elif ggchild.tag == 'unstable':
                                status['unstable'] = get_bool(ggchild.text)
                            elif ggchild.tag == 'failed':
                                status['failed'] = get_bool(ggchild.text)
                            elif ggchild.tag == 'aborted':
                                status['aborted'] = get_bool(ggchild.text)
                            elif ggchild.tag == 'disabled':
                                status['disabled'] = get_bool(ggchild.text)
                            elif ggchild.tag == 'stable':
                                status['stable'] = get_bool(ggchild.text)
                            else:
                                raise NotImplementedError("cannot handle XML %s" % ggchild.tag)
                    # Need to gen raw for filters, not implemented at all
                    else:
                        filters = {}  # Empty out filters
                        raw_xml = []
                        gen_raw(child, raw_xml)
                        raw_str_xml = raw_xml[0]['raw']['xml']
                        # Needs to be ['raw']['xml'], not [0]['raw']['xml'],
                        #   as view is a dictionary
                        if 'raw' not in view:
                            view['raw'] = {'xml': raw_str_xml}
                        else:
                            view['raw']['xml'] += raw_str_xml
                        break
                # End of jobFilters loop
                if filters:
                    view['job-filters'] = filters
            # End of jobFilters
            elif child.tag == 'jobNames':
                jobs = []
                for gchild in child:
                    if gchild.tag == 'string':
                        jobs.append(gchild.text)
                if jobs:
                    view['job-name'] = jobs
            elif child.tag == 'columns':
                if len(child) == 0:
                    continue
                columns = []
                for gchild in child:
                    if gchild.tag in self.COLUMN_DICT:
                        columns.append(self.COLUMN_DICT[gchild.tag])
                view['columns'] = columns
            elif child.tag == 'recurse':
                view['recurse'] = get_bool(child.text)
            elif child.tag == 'includeRegex':
                view['regex'] = child.text
            elif child.tag == 'statusFilter':
                view['status-filter'] = get_bool(child.text)
            elif child.tag == 'properties':
                # Not sure what this tag is for, doesn't seem important
                continue
            else:
                raise NotImplementedError("cannot handle XML %s" % child.tag)
        yml_parent.update(view)
예제 #17
0
def gerrittrigger(top, parent):
    mapper = Mapper({
        "gerritBuildStartedVerifiedValue":
        ("gerrit-build-started-verified-value", int),
        "gerritBuildStartedCodeReviewValue":
        ("gerrit-build-started-codereview-value", int),
        "gerritBuildSuccessfulVerifiedValue":
        ("gerrit-build-successful-verified-value", int),
        "gerritBuildSuccessfulCodeReviewValue":
        ("gerrit-build-successful-codereview-value", int),
        "gerritBuildFailedVerifiedValue":
        ("gerrit-build-failed-verified-value", int),
        "gerritBuildFailedCodeReviewValue":
        ("gerrit-build-failed-codereview-value", int),
        "gerritBuildUnstableVerifiedValue":
        ("gerrit-build-unstable-verified-value", int),
        "gerritBuildUnstableCodeReviewValue":
        ("gerrit-build-unstable-codereview-value", int),
        "gerritBuildNotBuiltVerifiedValue":
        ("gerrit-build-notbuilt-verified-value", int),
        "gerritBuildNotBuiltCodeReviewValue":
        ("gerrit-build-notbuilt-codereview-value", int),
        "silentMode": ("silent", bool),
        "silentStartMode": ("silent-start", bool),
        "escapeQuotes": ("escape-quotes", bool),
        "dependencyJobsNames": ("dependency-jobs", str),
        "nameAndEmailParameterMode": ("name-and-email-parameter-mode", str),
        "commitMessageParameterMode": ("commit-message-parameter-mode", str),
        "changeSubjectParameterMode": ("change-subject-parameter-mode", str),
        "commentTextParameterMode": ("comment-text-parameter-mode", str),
        "buildStartMessage": ("start-message", str),
        "buildFailureMessage": ("failure-message", str),
        "buildSuccessfulMessage": ("successful-message", str),
        "buildUnstableMessage": ("unstable-message", str),
        "buildNotBuiltMessage": ("notbuilt-message", str),
        "buildUnsuccessfulFilepath": ("failure-message-file", str),
        "customUrl": ("custom-url", str),
        "serverName": ("server-name", str),
        "dynamicTriggerConfiguration": ("dynamic-trigger-enabled", bool),
        "triggerConfigURL": ("dynamic-trigger-url", str),
    })
    gerrit_trigger = {}
    for child in top:
        if mapper.map_element(child, gerrit_trigger):
            pass  # Handled by the mapper.
        elif child.tag == "gerritProjects":
            gerrit_trigger["projects"] = __gerrit_process_gerrit_projects(
                child)
        elif child.tag == "dynamicGerritProjects":
            pass  # No implementation by JJB
        elif child.tag == "spec":
            pass  # Not needed in yml
        elif child.tag == "skipVote":
            skip_vote = {}
            for attribute in child:
                if attribute.tag == "onSuccessful":
                    skip_vote["successful"] = get_bool(attribute.text)
                if attribute.tag == "onFailed":
                    skip_vote["failed"] = get_bool(attribute.text)
                if attribute.tag == "onUnstable":
                    skip_vote["unstable"] = get_bool(attribute.text)
                if attribute.tag == "onNotBuilt":
                    skip_vote["notbuilt"] = get_bool(attribute.text)
            gerrit_trigger["skip-vote"] = skip_vote
        elif child.tag == "notificationLevel":
            if child.text is None:
                gerrit_trigger["notification-level"] = "NONE"
            else:
                gerrit_trigger["notification-level"] = child.text
        elif child.tag == "triggerOnEvents":
            gerrit_trigger["trigger-on"] = __gerrit_process_trigger_on_events(
                child)
        elif child.tag == "gerritTriggerTimerTask":
            pass  # Unconfigurable Attribute
        elif child.tag == "triggerInformationAction":
            pass  # Unconfigurable Attribute
        else:
            raise NotImplementedError(
                "Not implemented Gerrit Trigger Plugin's attribute: ",
                child.tag)
    parent.append({'gerrit': gerrit_trigger})
예제 #18
0
def concurrentbuild(top, parent):
    parent.append(['concurrent', get_bool(top.text)])
예제 #19
0
def blockbuildwhenupstreambuilding(top, parent):
    parent.append(['block-upstream', get_bool(top.text)])
예제 #20
0
def disabled(top, parent):
    parent.append(['disabled', get_bool(top.text)])
예제 #21
0
 def gen_yml(self, yml_parent, data):
     yml_parent.append(['lightweight-checkout', get_bool(data.text)])