Create project

Prev Next

Available in Classic and VPC

Create a deployment project.

Note

To integrate File Safer or Cloud Log Analytics services when creating a project, perform the following tasks first.

Request

This section describes the request format. The method and URI are as follows:

Method URI
POST /api/v1/project

Request headers

For information about the headers common to all SourceBuild APIs, see SourceBuild request headers.

Request body

You can include the following data in the body of your request:

Field Type Required Description
name String Required Project name
  • ;Enter 1-80 characters by combining English letters, numbers, and special characters "_" and "-".
  • You can't enter the same name as an existing build project.
description String Optional Project description
source Object Required Source storage information
source.type String Required Source storage type
  • SourceCommit (valid value)
source.config Object Required Source storage repository information
source.config.repository String Required Source storage repository name
source.config.branch String Required Source storage repository branch name
env Object Required Build environment information
env.compute Object Required Build environment computing type information
env.compute.id Number Required Computing type ID
env.platform Object Required Build environment platform information
env.platform.type String Required Image storage type
  • SourceBuild | ContainerRegistry | PublicRegistry
    • SourceBuild: image managed by SourceBuild
    • ContainerRegistry: Container Registry image
    • PublicRegistry: public registry image
env.platform.config Object Required Build environment settings
env.platform.config.os Object Conditional Operating system information
  • If env.platform.type is SourceBuild, it must be entered including sub-information.
env.platform.config.os.id Number Conditional Operating system ID
env.platform.config.runtime Object Conditional Runtime information
  • If env.platform.type is SourceBuild, it must be entered including sub-information.
env.platform.config.runtime.id Number Conditional Runtime type ID
env.platform.config.runtime.version Object Conditional Runtime version information
env.platform.config.runtime.version.id Number Conditional Runtime version ID
env.platform.config.registry Object Conditional Registry information
env.platform.config.image String Conditional Image name
  • Required if env.platform.type is ContainerRegistry or PublicRegistry
env.platform.config.tag String Conditional Image tag name
  • Required if env.platform.type is ContainerRegistry or PublicRegistry
env.docker Object Optional Docker engine information
env.docker.use Boolean Optional Inclusion status of Docker engine for Docker build
  • true | false (default)
    • true: include
    • false: not include
env.docker.id Number Conditional Docker engine version ID
env.timeout Number Optional Build execution timeout (minute)
  • 5-540 (default: 5)
env.envVars Array Optional Build environment variable information
cmd Object Optional Build command information
cmd.pre Array Optional Command before build
cmd.build Array Optional Command during build
cmd.post Array Optional Command after build
cmd.dockerbuild Object Conditional Docker image build information
  • If cmd.dockerbuild.use is true, it must be entered including sub-information.
    • However, cmd.dockerbuild.latest is optional.
cmd.dockerbuild.use Boolean Optional Whether to use Docker image build settings
  • true | false (default)
    • true: use
      • It is available only if env.docker.use is true.
    • false: not use
cmd.dockerbuild.dockerfile String Conditional dockerfile path
cmd.dockerbuild.registry String Conditional Container Registry name
cmd.dockerbuild.image String Conditional Image name
cmd.dockerbuild.tag String Conditional Image tag name
cmd.dockerbuild.latest Boolean Optional Whether to set latest tag
  • true | false (default)
    • true: set
    • false: not set
artifact Object Conditional Build result storage information
  • If artifact.use is true, it must be entered including sub-information.
artifact.use Boolean Optional Whether to save build results
  • true | false (default)
    • true: save
    • false: not save
  • The build results are saved as a compressed file (*.zip).
artifact.path Array Conditional Build result path
  • Required if artifact.use is true
artifact.storage.bucket String Conditional Object Storage bucket name to store the results
  • Required if artifact.use is true
artifact.storage.path String Conditional Object Storage bucket path to store the results
  • Required if artifact.use is true
artifact.storage.filename String Conditional File name to store the results
  • Required if artifact.use is true
artifact.backup Boolean Optional Whether to back up results
  • true | false (default)
    • true: back up
    • false: no backup
cache Object Optional Post-build image storage information
  • If cache.use is true, it must be entered including sub-information.
    • However, cache.latest is optional.
cache.use Boolean Optional Whether to store image after build completion
  • true | false (default)
    • true: save
    • false: not save
cache.registry String Conditional Container Registry name
  • Required if cache.use is true
cache.image String Conditional Image name
  • Required if cache.use is true
cache.tag String Conditional Image tag name
  • Required if cache.use is true
cache.latest Boolean Optional Whether to set latest tag
  • true | false (default)
    • true: set
    • false: not set
linked Object Optional Integrated service information
linked.CloudLogAnalytics Boolean Optional Cloud Log Analytics integration
  • true | false (default)
    • true: integrate
    • false: not integrate
linked.FileSafer Boolean Optional File Safer integration
  • true | false (default)
    • true: integrate
    • false: not integrate

envVars

The following describes envVars.

Field Type Required Description
env.envVars.key String Optional Environment variable key
env.envVars.value String Optional Environment variable value

Request example

The request example is as follows:

curl --location --request POST 'https://sourcebuild.apigw.ntruss.com/api/v1/project' \
--header 'x-ncp-iam-access-key: {Access Key}' \
--header 'x-ncp-apigw-timestamp: {Timestamp}' \
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
--data '{
    "name": "Build001",
    "description": "Build001",
    "source": {
        "type": "SourceCommit",
        "config": {
            "repository": "repository001", 
            "branch": "master"
        }
    },
    "env": {
        "compute": {
            "id": 1
            },
        "platform": {
            "type": "SourceBuild",
            "config": {
                "os": {
                    "id": 1
                    },
                "runtime": {
                    "id": 5,
                    "version": {
                        "id": 27
                    }
                }    
            }
        },
        "docker": {
           "use": true,
           "id": 1
        },
        "timeout": 60,
        "envVars": [
            {
                "key": "env1",
                "value": "value1"
            }
        ]
    },
    "cmd": {
       "pre": [],
       "build": [],
       "post": [],
       "dockerbuild": {
           "use": false,
           "dockerfile": "",
           "registry": "",
           "image": "",
           "tag": "",
           "latest": false
       }
    },
    "artifact": {
        "use": false,
        "path": [],
        "storage": {
            "bucket": "string",
            "path": "string",
            "filename": "string"
        },
        "backup": false
    },
    "cache": {
        "use": false,
        "registry": "",
        "image": "",
        "tag": "",
        "latest": false
    },
    "linked": {
        "CloudLogAnalytics": false,
        "FileSafer": false
    }
}'

Response

This section describes the response format.

Response body

The response body includes the following data:

Field Type Required Description
result Object - Response result
result.id Number - Project ID
result.name String - Project name

Response status codes

For information about the response status codes common to all SourceBuild APIs, see SourceBuild response status codes.

Response example

The response example is as follows:

{
    "result": {
        "id": 20***,
        "name": "Build001"
    }
}