Skip to content

Submit container image build

client.Build.New(ctx, body) (*AgentexCloudBuild, error)
POST/v5/builds

Create a container image build record.

This multipart request accepts exactly one image source. Provide context_archive to stream a tar.gz build context to the configured cloud build provider, or provide image_url to register an existing tagged image as an immediately successful build without invoking the provider. build_args and platform apply only to archive builds.

Exactly one of agent_name or agent_id must identify the target agent. agent_name creates a new build-only agent and must be unused. agent_id targets an existing agent. Archive builds normally return in a queued or running state; prebuilt images can immediately be passed to Cloud Deploy using the returned build ID. Archives must be non-empty and no larger than 500 MB.

ParametersExpand Collapse
body BuildNewParams
ImageName param.Field[string]

Name for the built image

AgentID param.Field[string]Optional

ID of the existing agent this build targets

AgentName param.Field[string]Optional

Name of the brand-new agent to create from this build

BuildArgs param.Field[string]Optional

JSON string of build arguments

ContextArchive param.Field[Reader]Optional

tar.gz archive containing the build context (Dockerfile and any files needed for the build)

ImageTag param.Field[string]Optional

Tag for the built image

ImageURL param.Field[string]Optional

Existing tagged image to register instead of running a build

Platform param.Field[BuildNewParamsPlatform]Optional

Target platform for the Docker build. Defaults to the build host’s native architecture when not specified.

const BuildNewParamsPlatformLinuxAmd64 BuildNewParamsPlatform = "linux/amd64"
const BuildNewParamsPlatformLinuxArm64 BuildNewParamsPlatform = "linux/arm64"
const BuildNewParamsPlatformLinuxArmV7 BuildNewParamsPlatform = "linux/arm/v7"
SourceCommit param.Field[string]Optional

Git commit the build context was at.

maxLength64
SourceDirty param.Field[bool]Optional

Whether the work tree had uncommitted changes at build time.

SourceRef param.Field[string]Optional

Git branch or tag for source_commit.

maxLength4096
SourceRepo param.Field[string]Optional

Normalized git remote the build context came from.

maxLength2048
SourceSubpath param.Field[string]Optional

Build-context path relative to the repo root.

maxLength4096
WorkingTreeHash param.Field[string]Optional

Deterministic SHA-256 content hash of the build inputs.

maxLength64
ReturnsExpand Collapse
type AgentexCloudBuild struct{…}
ID string

The unique identifier of the entity.

AccountID string

The ID of the account that owns the given entity.

AgentName string

The name of the agent that this build belongs to

BuildStatus AgentexCloudBuildBuildStatus

The current build lifecycle status

One of the following:
const AgentexCloudBuildBuildStatusQueued AgentexCloudBuildBuildStatus = "queued"
const AgentexCloudBuildBuildStatusRunning AgentexCloudBuildBuildStatus = "running"
const AgentexCloudBuildBuildStatusSuccess AgentexCloudBuildBuildStatus = "success"
const AgentexCloudBuildBuildStatusFailed AgentexCloudBuildBuildStatus = "failed"
const AgentexCloudBuildBuildStatusCancelling AgentexCloudBuildBuildStatus = "cancelling"
const AgentexCloudBuildBuildStatusCancelled AgentexCloudBuildBuildStatus = "cancelled"
const AgentexCloudBuildBuildStatusDeleting AgentexCloudBuildBuildStatus = "deleting"
const AgentexCloudBuildBuildStatusDeleteFailed AgentexCloudBuildBuildStatus = "delete_failed"
const AgentexCloudBuildBuildStatusTimedOut AgentexCloudBuildBuildStatus = "timed_out"
const AgentexCloudBuildBuildStatusError AgentexCloudBuildBuildStatus = "error"
const AgentexCloudBuildBuildStatusUnknown AgentexCloudBuildBuildStatus = "unknown"
CloudProviderBuildID string

The unique identifier of the build from the cloud provider, or an internal UUID when an existing image is copied without a provider build.

CreatedAt Time

The date and time when the entity was created in ISO format.

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
ImageName string

The name of the container image to build.

ImageTag string

The tag for the container image.

SourceCommit string

Git commit the build context was at, when a git work tree.

SourceDirty bool

Whether the work tree had uncommitted changes at build time (null outside git).

SourceRef string

Git branch or tag for source_commit, when resolvable.

SourceRepo string

Normalized git remote the build context came from (host/path, no credentials).

SourceSubpath string

Build-context path relative to the repo root (which agent, in a monorepo).

WorkingTreeHash string

Deterministic SHA-256 content hash of the build inputs (not the tarball).

AgentID stringOptional

The UUID of the agent that this build belongs to

BuildEndTime TimeOptional

When the cloud provider finished the build

formatdate-time
BuildStartTime TimeOptional

When the cloud provider started the build

formatdate-time
ImageURL stringOptional

The URL of the container image. This is not guaranteed to be present until the build is complete.

Object AgentexCloudBuildObjectOptional

Submit container image build

package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  agentexCloudBuild, err := client.Build.New(context.TODO(), sgpdev.BuildNewParams{
    ImageName: "image_name",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", agentexCloudBuild.ID)
}
{
  "id": "id",
  "account_id": "account_id",
  "agent_name": "agent_name",
  "build_status": "queued",
  "cloud_provider_build_id": "cloud_provider_build_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "image_name": "image_name",
  "image_tag": "image_tag",
  "source_commit": "source_commit",
  "source_dirty": true,
  "source_ref": "source_ref",
  "source_repo": "source_repo",
  "source_subpath": "source_subpath",
  "working_tree_hash": "working_tree_hash",
  "agent_id": "agent_id",
  "build_end_time": "2019-12-27T18:11:19.117Z",
  "build_start_time": "2019-12-27T18:11:19.117Z",
  "image_url": "image_url",
  "object": "agentex_cloud_build"
}
Returns Examples
{
  "id": "id",
  "account_id": "account_id",
  "agent_name": "agent_name",
  "build_status": "queued",
  "cloud_provider_build_id": "cloud_provider_build_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "image_name": "image_name",
  "image_tag": "image_tag",
  "source_commit": "source_commit",
  "source_dirty": true,
  "source_ref": "source_ref",
  "source_repo": "source_repo",
  "source_subpath": "source_subpath",
  "working_tree_hash": "working_tree_hash",
  "agent_id": "agent_id",
  "build_end_time": "2019-12-27T18:11:19.117Z",
  "build_start_time": "2019-12-27T18:11:19.117Z",
  "image_url": "image_url",
  "object": "agentex_cloud_build"
}