Skip to content

create_project

create_project(
    name: ProjectName,
    source: ProjectSource,
    artifacts: ProjectArtifacts,
    environment: ProjectEnvironment,
    service_role: NonEmptyString,
    *,
    config_overrides: Optional[CodeBuildClientConfig] = None,
    description: Optional[ProjectDescription] = None,
    secondary_sources: Optional[ProjectSources] = None,
    source_version: Optional[String] = None,
    secondary_source_versions: Optional[ProjectSecondarySourceVersions] = None,
    secondary_artifacts: Optional[ProjectArtifactsList] = None,
    cache: Optional[ProjectCache] = None,
    timeout_in_minutes: Optional[BuildTimeOut] = None,
    queued_timeout_in_minutes: Optional[TimeOut] = None,
    encryption_key: Optional[NonEmptyString] = None,
    tags: Optional[TagList] = None,
    vpc_config: Optional[VpcConfig] = None,
    badge_enabled: Optional[WrapperBoolean] = None,
    logs_config: Optional[LogsConfig] = None,
    file_system_locations: Optional[ProjectFileSystemLocations] = None,
    build_batch_config: Optional[ProjectBuildBatchConfig] = None,
    concurrent_build_limit: Optional[WrapperInt] = None,
    auto_retry_limit: Optional[WrapperInt] = None,
) -> CreateProjectOutput

Creates a build project.

Parameters:

  • name (ProjectName) –

    The name of the build project.

  • description (Optional[ProjectDescription], default: None ) –

    A description that makes the build project easy to identify.

  • source (ProjectSource) –

    Information about the build input source code for the build project.

  • secondary_sources (Optional[ProjectSources], default: None ) –

    An array of ProjectSource objects.

  • source_version (Optional[String], default: None ) –

    A version of the build input to be built for this project. If not specified, the latest version is used. If specified, it must be one of:

    • For CodeCommit: the commit ID, branch, or Git tag to use.

    • For GitHub: the commit ID, pull request ID, branch name, or tag name that corresponds to the version of the source code you want to build. If a pull request ID is specified, it must use the format pr/pull-request-ID (for example pr/25). If a branch name is specified, the branch's HEAD commit ID is used. If not specified, the default branch's HEAD commit ID is used.

    • For GitLab: the commit ID, branch, or Git tag to use.

    • For Bitbucket: the commit ID, branch name, or tag name that corresponds to the version of the source code you want to build. If a branch name is specified, the branch's HEAD commit ID is used. If not specified, the default branch's HEAD commit ID is used.

    • For Amazon S3: the version ID of the object that represents the build input ZIP file to use.

    If sourceVersion is specified at the build level, then that version takes precedence over this sourceVersion (at the project level).

    For more information, see Source Version Sample with CodeBuild in the CodeBuild User Guide.

  • secondary_source_versions (Optional[ProjectSecondarySourceVersions], default: None ) –

    An array of ProjectSourceVersion objects. If secondarySourceVersions is specified at the build level, then they take precedence over these secondarySourceVersions (at the project level).

  • artifacts (ProjectArtifacts) –

    Information about the build output artifacts for the build project.

  • secondary_artifacts (Optional[ProjectArtifactsList], default: None ) –

    An array of ProjectArtifacts objects.

  • cache (Optional[ProjectCache], default: None ) –

    Stores recently used information so that it can be quickly accessed at a later time.

  • environment (ProjectEnvironment) –

    Information about the build environment for the build project.

  • service_role (NonEmptyString) –

    The ARN of the IAM role that enables CodeBuild to interact with dependent Amazon Web Services services on behalf of the Amazon Web Services account.

  • timeout_in_minutes (Optional[BuildTimeOut], default: None ) –

    How long, in minutes, from 5 to 2160 (36 hours), for CodeBuild to wait before it times out any build that has not been marked as completed. The default is 60 minutes.

  • queued_timeout_in_minutes (Optional[TimeOut], default: None ) –

    The number of minutes a build is allowed to be queued before it times out.

  • encryption_key (Optional[NonEmptyString], default: None ) –

    The Key Management Service customer master key (CMK) to be used for encrypting the build output artifacts.

    You can use a cross-account KMS key to encrypt the build output artifacts if your service role has permission to that key.

    You can specify either the Amazon Resource Name (ARN) of the CMK or, if available, the CMK's alias (using the format alias/).

  • tags (Optional[TagList], default: None ) –

    A list of tag key and value pairs associated with this build project.

    These tags are available for use by Amazon Web Services services that support CodeBuild build project tags.

  • vpc_config (Optional[VpcConfig], default: None ) –

    VpcConfig enables CodeBuild to access resources in an Amazon VPC.

    If you're using compute fleets during project creation, do not provide vpcConfig.

  • badge_enabled (Optional[WrapperBoolean], default: None ) –

    Set this to true to generate a publicly accessible URL for your project's build badge.

  • logs_config (Optional[LogsConfig], default: None ) –

    Information about logs for the build project. These can be logs in CloudWatch Logs, logs uploaded to a specified S3 bucket, or both.

  • file_system_locations (Optional[ProjectFileSystemLocations], default: None ) –

    An array of ProjectFileSystemLocation objects for a CodeBuild build project. A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System.

  • build_batch_config (Optional[ProjectBuildBatchConfig], default: None ) –

    A ProjectBuildBatchConfig object that defines the batch build options for the project.

  • concurrent_build_limit (Optional[WrapperInt], default: None ) –

    The maximum number of concurrent builds that are allowed for this project.

    New builds are only started if the current number of builds is less than or equal to this limit. If the current build count meets this limit, new builds are throttled and are not run.

  • auto_retry_limit (Optional[WrapperInt], default: None ) –

    The maximum number of additional automatic retries after a failed build. For example, if the auto-retry limit is set to 2, CodeBuild will call the RetryBuild API to automatically retry your build for up to 2 additional times.

Raises:

Source code in docs_src/capo_codebuild/_services/code_build.py
def create_project(
    self,
    name: "capo_codebuild.types.project_name.ProjectName",
    source: "capo_codebuild.types.project_source.ProjectSource",
    artifacts: "capo_codebuild.types.project_artifacts.ProjectArtifacts",
    environment: "capo_codebuild.types.project_environment.ProjectEnvironment",
    service_role: "capo_codebuild.types.non_empty_string.NonEmptyString",
    *,
    config_overrides: Optional[CodeBuildClientConfig] = None,
    description: Optional[
        "capo_codebuild.types.project_description.ProjectDescription"
    ] = None,
    secondary_sources: Optional[
        "capo_codebuild.types.project_sources.ProjectSources"
    ] = None,
    source_version: Optional["capo_codebuild.types.string.String"] = None,
    secondary_source_versions: Optional[
        "capo_codebuild.types.project_secondary_source_versions.ProjectSecondarySourceVersions"
    ] = None,
    secondary_artifacts: Optional[
        "capo_codebuild.types.project_artifacts_list.ProjectArtifactsList"
    ] = None,
    cache: Optional["capo_codebuild.types.project_cache.ProjectCache"] = None,
    timeout_in_minutes: Optional[
        "capo_codebuild.types.build_time_out.BuildTimeOut"
    ] = None,
    queued_timeout_in_minutes: Optional[
        "capo_codebuild.types.time_out.TimeOut"
    ] = None,
    encryption_key: Optional[
        "capo_codebuild.types.non_empty_string.NonEmptyString"
    ] = None,
    tags: Optional["capo_codebuild.types.tag_list.TagList"] = None,
    vpc_config: Optional["capo_codebuild.types.vpc_config.VpcConfig"] = None,
    badge_enabled: Optional[
        "capo_codebuild.types.wrapper_boolean.WrapperBoolean"
    ] = None,
    logs_config: Optional["capo_codebuild.types.logs_config.LogsConfig"] = None,
    file_system_locations: Optional[
        "capo_codebuild.types.project_file_system_locations.ProjectFileSystemLocations"
    ] = None,
    build_batch_config: Optional[
        "capo_codebuild.types.project_build_batch_config.ProjectBuildBatchConfig"
    ] = None,
    concurrent_build_limit: Optional[
        "capo_codebuild.types.wrapper_int.WrapperInt"
    ] = None,
    auto_retry_limit: Optional[
        "capo_codebuild.types.wrapper_int.WrapperInt"
    ] = None,
) -> "capo_codebuild.types.create_project_output.CreateProjectOutput":
    """<p>Creates a build project.</p>

    Args:
        name: <p>The name of the build project.</p>
        description: <p>A description that makes the build project easy to identify.</p>
        source: <p>Information about the build input source code for the build project.</p>
        secondary_sources: <p>An array of <code>ProjectSource</code> objects. </p>
        source_version: <p>A version of the build input to be built for this project. If not specified, the latest version is used. If specified, it must be one of: </p> <ul> <li> <p>For CodeCommit: the commit ID, branch, or Git tag to use.</p> </li> <li> <p>For GitHub: the commit ID, pull request ID, branch name, or tag name that corresponds to the version of the source code you want to build. If a pull request ID is specified, it must use the format <code>pr/pull-request-ID</code> (for example <code>pr/25</code>). If a branch name is specified, the branch's HEAD commit ID is used. If not specified, the default branch's HEAD commit ID is used.</p> </li> <li> <p>For GitLab: the commit ID, branch, or Git tag to use.</p> </li> <li> <p>For Bitbucket: the commit ID, branch name, or tag name that corresponds to the version of the source code you want to build. If a branch name is specified, the branch's HEAD commit ID is used. If not specified, the default branch's HEAD commit ID is used.</p> </li> <li> <p>For Amazon S3: the version ID of the object that represents the build input ZIP file to use.</p> </li> </ul> <p>If <code>sourceVersion</code> is specified at the build level, then that version takes precedence over this <code>sourceVersion</code> (at the project level). </p> <p>For more information, see <a href="https://docs.aws.amazon.com/codebuild/latest/userguide/sample-source-version.html">Source Version Sample with CodeBuild</a> in the <i>CodeBuild User Guide</i>. </p>
        secondary_source_versions: <p>An array of <code>ProjectSourceVersion</code> objects. If <code>secondarySourceVersions</code> is specified at the build level, then they take precedence over these <code>secondarySourceVersions</code> (at the project level). </p>
        artifacts: <p>Information about the build output artifacts for the build project.</p>
        secondary_artifacts: <p>An array of <code>ProjectArtifacts</code> objects. </p>
        cache: <p>Stores recently used information so that it can be quickly accessed at a later time.</p>
        environment: <p>Information about the build environment for the build project.</p>
        service_role: <p>The ARN of the IAM role that enables CodeBuild to interact with dependent Amazon Web Services services on behalf of the Amazon Web Services account.</p>
        timeout_in_minutes: <p>How long, in minutes, from 5 to 2160 (36 hours), for CodeBuild to wait before it times out any build that has not been marked as completed. The default is 60 minutes.</p>
        queued_timeout_in_minutes: <p>The number of minutes a build is allowed to be queued before it times out. </p>
        encryption_key: <p>The Key Management Service customer master key (CMK) to be used for encrypting the build output artifacts.</p> <note> <p>You can use a cross-account KMS key to encrypt the build output artifacts if your service role has permission to that key. </p> </note> <p>You can specify either the Amazon Resource Name (ARN) of the CMK or, if available, the CMK's alias (using the format <code>alias/<alias-name></code>). </p>
        tags: <p>A list of tag key and value pairs associated with this build project.</p> <p>These tags are available for use by Amazon Web Services services that support CodeBuild build project tags.</p>
        vpc_config: <p>VpcConfig enables CodeBuild to access resources in an Amazon VPC.</p> <note> <p>If you're using compute fleets during project creation, do not provide vpcConfig.</p> </note>
        badge_enabled: <p>Set this to true to generate a publicly accessible URL for your project's build badge.</p>
        logs_config: <p>Information about logs for the build project. These can be logs in CloudWatch Logs, logs uploaded to a specified S3 bucket, or both. </p>
        file_system_locations: <p> An array of <code>ProjectFileSystemLocation</code> objects for a CodeBuild build project. A <code>ProjectFileSystemLocation</code> object specifies the <code>identifier</code>, <code>location</code>, <code>mountOptions</code>, <code>mountPoint</code>, and <code>type</code> of a file system created using Amazon Elastic File System. </p>
        build_batch_config: <p>A <a>ProjectBuildBatchConfig</a> object that defines the batch build options for the project.</p>
        concurrent_build_limit: <p>The maximum number of concurrent builds that are allowed for this project.</p> <p>New builds are only started if the current number of builds is less than or equal to this limit. If the current build count meets this limit, new builds are throttled and are not run.</p>
        auto_retry_limit: <p>The maximum number of additional automatic retries after a failed build. For example, if the auto-retry limit is set to 2, CodeBuild will call the <code>RetryBuild</code> API to automatically retry your build for up to 2 additional times.</p>

    Raises:
        capo_codebuild.errors.account_limit_exceeded_exception.AccountLimitExceededException: <p>An Amazon Web Services service limit was exceeded for the calling Amazon Web Services account.</p>
        capo_codebuild.errors.invalid_input_exception.InvalidInputException: <p>The input value that was provided is not valid.</p>
        capo_codebuild.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The specified Amazon Web Services resource cannot be created, because an Amazon Web Services resource with the same settings already exists.</p>
        capo_codebuild.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_codebuild.types.create_project_input.CreateProjectInput]",
    ) -> OperationResponse[
        "capo_codebuild.types.create_project_output.CreateProjectOutput"
    ]:
        import capo_codebuild._operations.code_build_20161006.create_project

        output, http_response = (
            capo_codebuild._operations.code_build_20161006.create_project.create_project(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateProject")
    )
    input_: capo_codebuild.types.create_project_input.CreateProjectInput = {
        "name": name,
        "source": source,
        "artifacts": artifacts,
        "environment": environment,
        "service_role": service_role,
    }
    if description is not None:
        input_["description"] = description
    if secondary_sources is not None:
        input_["secondary_sources"] = secondary_sources
    if source_version is not None:
        input_["source_version"] = source_version
    if secondary_source_versions is not None:
        input_["secondary_source_versions"] = secondary_source_versions
    if secondary_artifacts is not None:
        input_["secondary_artifacts"] = secondary_artifacts
    if cache is not None:
        input_["cache"] = cache
    if timeout_in_minutes is not None:
        input_["timeout_in_minutes"] = timeout_in_minutes
    if queued_timeout_in_minutes is not None:
        input_["queued_timeout_in_minutes"] = queued_timeout_in_minutes
    if encryption_key is not None:
        input_["encryption_key"] = encryption_key
    if tags is not None:
        input_["tags"] = tags
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if badge_enabled is not None:
        input_["badge_enabled"] = badge_enabled
    if logs_config is not None:
        input_["logs_config"] = logs_config
    if file_system_locations is not None:
        input_["file_system_locations"] = file_system_locations
    if build_batch_config is not None:
        input_["build_batch_config"] = build_batch_config
    if concurrent_build_limit is not None:
        input_["concurrent_build_limit"] = concurrent_build_limit
    if auto_retry_limit is not None:
        input_["auto_retry_limit"] = auto_retry_limit

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output