예제 #1
0
  def Args(parser):
    """Register flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    """

    parser.display_info.AddFormat("""
          table(
            name,
            createTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'),
            status
          )
        """)

    # Allow trigger config to be specified on the command line or file
    trigger_config = parser.add_mutually_exclusive_group(required=True)
    trigger_config.add_argument(
        '--trigger_config',
        help='Path to Build Trigger config file. See https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.triggers#BuildTrigger',
        metavar='PATH',
    )

    # Trigger configuration
    flag_config = trigger_config.add_argument_group(
        help='Flag based trigger configuration')
    flag_config.add_argument(
        '--repo_owner', help='Owner of the GitHub Repository.', required=True)

    flag_config.add_argument(
        '--repo_name', help='Name of the GitHub Repository.', required=True)
    ref_config = flag_config.add_mutually_exclusive_group(required=True)
    trigger_utils.AddBranchPattern(ref_config)
    trigger_utils.AddTagPattern(ref_config)
    pr_config = ref_config.add_argument_group(help='Pull Request settings')
    pr_config.add_argument(
        '--pull_request_pattern',
        metavar='REGEX',
        help="""\
A regular expression specifying which base git branch to match for
pull request events.

This pattern is used as a regex search for the base branch (the branch you are
trying to merge into) for pull request updates.
For example, --pull-request-pattern=foo will match "foo", "foobar", and "barfoo".

The syntax of the regular expressions accepted is the syntax accepted by
RE2 and described at https://github.com/google/re2/wiki/Syntax.
""")
    pr_config.add_argument(
        '--comment_control',
        help='Require a repository collaborator owner to comment \'/gcbrun\' on a pull request before running the build.',
        action='store_true')

    trigger_utils.AddBuildConfigArgs(flag_config)
예제 #2
0
    def Args(parser):
        """Register flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    """
        messages = cloudbuild_util.GetMessagesModule()
        flag_config = trigger_utils.AddTriggerArgs(parser)
        flag_config.add_argument('--repo-slug',
                                 help='Bitbucket Server repository slug.',
                                 required=True)
        flag_config.add_argument('--project-key',
                                 help='Bitbucket Server project key.',
                                 required=True)
        flag_config.add_argument('--bitbucket-server-config-resource',
                                 help='Bitbucket Server config resource name.',
                                 required=True)
        ref_config = flag_config.add_mutually_exclusive_group(required=True)
        trigger_utils.AddBranchPattern(ref_config)
        trigger_utils.AddTagPattern(ref_config)
        pr_config = ref_config.add_argument_group(help='Pull Request settings')
        pr_config.add_argument('--pull-request-pattern',
                               metavar='REGEX',
                               required=True,
                               help="""\
Regular expression specifying which base git branch to match for
pull request events.

This pattern is used as a regex search for the base branch (the branch you are
trying to merge into) for pull request updates.
For example, --pull-request-pattern=foo will match "foo", "foobar", and "barfoo".

The syntax of the regular expressions accepted is the syntax accepted by
RE2 and described at https://github.com/google/re2/wiki/Syntax.
""")
        pr_config.add_argument(
            '--comment-control',
            default=messages.PullRequestFilter.CommentControlValueValuesEnum.
            COMMENTS_ENABLED,
            help=
            'Require a repository collaborator or owner to comment \'/gcbrun\' on a pull request before running the build.'
        )

        trigger_utils.AddBuildConfigArgs(flag_config)
        trigger_utils.AddRepoEventArgs(flag_config)
    def Args(parser):
        """Register flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    """

        parser.display_info.AddFormat("""
          table(
            name,
            createTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'),
            status
          )
        """)

        trigger_config = parser.add_mutually_exclusive_group(required=True)

        # Allow trigger config to be specified on the command line or by file.
        trigger_config.add_argument('--trigger-config',
                                    metavar='PATH',
                                    help="""\
Path to a YAML or JSON file containing the trigger configuration.

For more details, see: https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.triggers
""")

        # Trigger configuration
        flag_config = trigger_config.add_argument_group(
            help='Flag based trigger configuration')
        flag_config.add_argument('--description',
                                 help='Build trigger description.')
        repo_spec = presentation_specs.ResourcePresentationSpec(
            '--repo',  # This defines how the "anchor" or leaf argument is named.
            repo_resource.GetRepoResourceSpec(),
            'Cloud Source Repository.',
            required=True,
            prefixes=False)
        concept_parsers.ConceptParser([repo_spec]).AddToParser(flag_config)
        ref_config = flag_config.add_mutually_exclusive_group(required=True)
        trigger_utils.AddBranchPattern(ref_config)
        trigger_utils.AddTagPattern(ref_config)

        trigger_utils.AddBuildConfigArgs(flag_config)
예제 #4
0
    def Args(parser):
        """Register flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    """

        flag_config = trigger_utils.AddTriggerArgs(parser)
        repo_spec = presentation_specs.ResourcePresentationSpec(
            '--repo',  # This defines how the "anchor" or leaf argument is named.
            repo_resource.GetRepoResourceSpec(),
            'Cloud Source Repository.',
            required=True,
            prefixes=False)
        concept_parsers.ConceptParser([repo_spec]).AddToParser(flag_config)
        ref_config = flag_config.add_mutually_exclusive_group(required=True)
        trigger_utils.AddBranchPattern(ref_config)
        trigger_utils.AddTagPattern(ref_config)

        trigger_utils.AddBuildConfigArgs(flag_config)