(cls, payload)
return cls._prefix_line(line, payload)
Create and return a one-line summary of the build
Create and return a one-line summary of the build
Create and return a one - line summary of the build
def _create_summary(cls, payload):
        """
        Create and return a one-line summary of the build
        """
        status_colour = {
            'SUCCESS': HookService.colors['GREEN'],
            'UNSTABLE': HookService.colors['ORANGE'],
            # documentation differs from implementation
            'FAILURE': HookService.colors['RED'],
            'FAILED': HookService.colors['RED']
        }.get(
            payload['build'].get('status', 'SUCCESS').upper(),
            HookService.colors['RED']
        )

        number = payload['build']['number']
        phase = payload['build']['phase'].lower()
        url = payload['build']['full_url']

        status = payload['build'].get('status', '').lower()
        if status:
            # make sure this string starts with a space or
            # the formatting won't look good (see fmt_string)
            status = ': {status_colour}{status}{RESET}'.format(
                status_colour=status_colour,
                status=status,
                **HookService.colors
            )

        commit = ''
        scm = payload['build'].get('scm', {})
        if scm.get('commit'):
            # space is important again
            commit = '({GREEN}{commit}{RESET}) '.format(
                commit=scm.get('commit')[:7],
                **HookService.colors
            )

        fmt_string = (
            '{ORANGE}jenkins{RESET} build {status_colour}#{number}{RESET} '
            '{commit}{phase}{status} {PINK}{url}{RESET}'
        )

        line = fmt_string.format(
            status_colour=status_colour,
            number=number,
            commit=commit,
            phase=phase,
            status=status,
            url=url,
            **HookService.colors
        )
        return cls._prefix_line(line, payload)
def _create_summary ( cls , payload ) : status_colour = { 'SUCCESS' : HookService . colors [ 'GREEN' ] , 'UNSTABLE' : HookService . colors [ 'ORANGE' ] , # documentation differs from implementation 'FAILURE' : HookService . colors [ 'RED' ] , 'FAILED' : HookService . colors [ 'RED' ] } . get ( payload [ 'build' ] . get ( 'status' , 'SUCCESS' ) . upper ( ) , HookService . colors [ 'RED' ] ) number = payload [ 'build' ] [ 'number' ] phase = payload [ 'build' ] [ 'phase' ] . lower ( ) url = payload [ 'build' ] [ 'full_url' ] status = payload [ 'build' ] . get ( 'status' , '' ) . lower ( ) if status : # make sure this string starts with a space or # the formatting won't look good (see fmt_string) status = ': {status_colour}{status}{RESET}' . format ( status_colour = status_colour , status = status , * * HookService . colors ) commit = '' scm = payload [ 'build' ] . get ( 'scm' , { } ) if scm . get ( 'commit' ) : # space is important again commit = '({GREEN}{commit}{RESET}) ' . format ( commit = scm . get ( 'commit' ) [ : 7 ] , * * HookService . colors ) fmt_string = ( '{ORANGE}jenkins{RESET} build {status_colour}#{number}{RESET} ' '{commit}{phase}{status} {PINK}{url}{RESET}' ) line = fmt_string . format ( status_colour = status_colour , number = number , commit = commit , phase = phase , status = status , url = url , * * HookService . colors ) return cls . _prefix_line ( line , payload )