unitycloudbuild

package module
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2018 License: MIT Imports: 17 Imported by: 0

README

Unity Cloud Build Tools

CLI tool for interacting with Unity Cloud Build.

This tool is not meant to be an exhaustive wrapper around every single Cloud Build endpoint, but instead it is meant to provide a quick way to accomplish common tasks.

See Releases for 64-bit Windows, Mac, and Linux binaries.

NAME:
   unity-cb-tool - A tool to interact with Unity Cloud Build

USAGE:
   unity-cb-tool [global options] command [command options] [arguments...]

VERSION:
   0.2.3

COMMANDS:
     builds   
     targets  
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --api-key value     Unity API key [$UNITY_API_KEY]
   --org-id value      Unity Organization ID [$UNITY_ORG_ID]
   --project-id value  Unity Project ID [$UNITY_PROJECT_ID]
   --json              If true, output responses in JSON
   --help, -h          show help
   --version, -v       print the version

By default, commands output human-readable data. If --json is specified as a root flag a more detailed JSON response will be outputted (e.g. unity-cb-tool --json targets list).

NOTE: In the examples below, the two target IDs 'windows-x64' and 'macos' are from one of my projects. The IDs for your project will be whatever you have setup for build targets in Cloud Build. The easiest way to find your target IDs is to run unity-cb-tool targets list.

Configuration

This tool requires you to specify your API key, organization ID, and project ID for any of the commands to work.

If the organization ID and project ID are not in the environment variables or not provided as an argument, the tool will attempt to locate your ProjectSettings.asset file and pull those values from it.

Another way to provide these config values are to specify them as environment variables:

  • API Key: UNITY_API_KEY
  • Org ID: UNITY_ORG_ID
  • Project ID: UNITY_PROJECT_ID

Alternatively you could specify each explicitly, e.g.:

unity-cb-tool --api-key MYAPIKEY --org-id my-org-id --project-id MYPROJECTID builds latest

Or via a combination of environment variables and explicit specification:

# Could stick these in your .bashrc or Windows environment
export UNITY_API_KEY=MYAPIKEY
export UNITY_ORG_ID=my-org-id

unity-cb-tool --project-id MYPROJECTID builds latest

Commands

targets list
NAME:
   unity-cb-tool targets list - List all build targets

USAGE:
   unity-cb-tool targets list [arguments...]
Example
unity-cb-tool targets list

---

Target: Windows x64
  ID:        windows-x64
  Enabled:   true
  AutoBuild: true
  Branch:    release
  Unity:     2018.1.2f1

Target: MacOS
  ID:        macos
  Enabled:   true
  AutoBuild: true
  Branch:    release
  Unity:     2018.1.2f1
builds list
NAME:
   unity-cb-tool builds list - List builds

USAGE:
   unity-cb-tool builds list [command options] [arguments...]

OPTIONS:
   --target-id value        Specific target ID or _all for all targets (default: "_all")
   --filter-status value    (queued, sentToBuilder, started, restarted, success, failure, canceled, unknown)
   --filter-platform value  (ios, android, webgl, osx, win, win64, linux)
   --limit value, -l value  If >0 show only the specified number of builds (default: 0)
Example
unity-cb-tool builds list --limit 10

---

Target: windows-x64, (Build #16)
  Status:   success
  Time:     12m15s
  Revision: 9102ca18b98706193a6b9d92d51cab8928bd7b97
  Download: https://unitycloud-build-user-svc-live-build.s3.amazonaws.com/...

Target: macos, (Build #15)
  Status:   success
  Time:     18m1s
  Revision: 9102ca18b98706193a6b9d92d51cab8928bd7b97
  Download: https://unitycloud-build-user-svc-live-build.s3.amazonaws.com/...

(truncated...)
builds latest
NAME:
   unity-cb-tool builds latest - List latest builds for every build target

USAGE:
   unity-cb-tool builds latest [command options] [arguments...]

OPTIONS:
   --success  If true, only show latest successful build
Examples

Get all the latest builds of any status.

unity-cb-tool builds latest

---

Target: macos, (Build #25)
  Created:  2018-06-19 18:52:56.402 +0000 UTC
  Status:   canceled
  Time:     17s

Target: Windows x64 (id=windows-x64)
  Build:    #16
  Status:   success
  Time:     17m13s
  Revision: 9102ca18b98706193a6b9d92d51cab8928bd7b97
  Download: https://unitycloud-build-user-svc-live-build.s3.amazonaws.com/...

Get all the latest successful builds.

unity-cb-tool builds latest --success

---

Target: Windows x64 (id=windows-x64)
  Build:    #16
  Status:   success
  Time:     17m13s
  Revision: 9102ca18b98706193a6b9d92d51cab8928bd7b97
  Download: https://unitycloud-build-user-svc-live-build.s3.amazonaws.com/...

Target: MacOS (id=macos)
  Build:    #15
  Status:   success
  Time:     18m3s
  Revision: 9102ca18b98706193a6b9d92d51cab8928bd7b97
  Download: https://unitycloud-build-user-svc-live-build.s3.amazonaws.com/...
builds status
NAME:
   unity-cb-tool builds status - Retrieve status of a build

USAGE:
   unity-cb-tool builds status [command options] [arguments...]

OPTIONS:
   --target-id value, -t value  Build target ID
   --build value, -b value      Build number for build target (default: -1)
   
Examples
unity-cb-tool builds status -t windows-x64 -b 16

---

Target: Windows x64 (id=windows-x64)
  Build:    #16
  Status:   success
  Time:     17m13s
  Revision: 9102ca18b98706193a6b9d92d51cab8928bd7b97
  Download: https://unitycloud-build-user-svc-live-build.s3.amazonaws.com/...

builds start
NAME:
   unity-cb-tool builds start - Start a build for a build target, or if --all is specified start builds for all enabled targets

USAGE:
   unity-cb-tool builds start [command options] [arguments...]

OPTIONS:
   --all                        If true, start builds on all enabled targets
   --clean                      Force a clean build.
   --target-id value, -t value  Build target ID
   
Examples

Start a build for a specific target.

unity-cb-tool builds start -t windows-x64

---

Target: windows-x64, (Build #33)
  Created:  2018-06-19 18:52:02.951 +0000 UTC
  Status:   queued
  Time:     0s

Start a build for all enabled targets.

unity-cb-tool builds start --all

---

Target: windows-x64, (Build #34)
  Created:  2018-06-19 18:52:56.397 +0000 UTC
  Status:   queued
  Time:     0s

Target: macos, (Build #25)
  Created:  2018-06-19 18:52:56.402 +0000 UTC
  Status:   queued
  Time:     0s

builds cancel
NAME:
   unity-cb-tool builds cancel - Cancel a build for a build target, or if --all is specified cancel all builds

USAGE:
   unity-cb-tool builds cancel [command options] [arguments...]

OPTIONS:
   --all                        If true, cancel all builds
   --target-id value, -t value  Build target ID
   --build value, -b value      Build number for build target (default: -1)
Examples

Cancel a specific build.

unity-cb-tool builds cancel -t windows-x64 -b 17

---

(no output)

Cancel all builds for a specific target.

unity-cb-tool builds cancel -t windows-x64 --all

---

(no output)

Cancel all builds for all targets.

unity-cb-tool builds cancel --all

---

(no output)
builds download
NAME:
   unity-cb-tool builds download - Download builds

USAGE:
   unity-cb-tool builds download [command options] [arguments...]

OPTIONS:
   --target-id value, -t value  Build target ID
   --build value, -b value      Build number for build target (default: -1)
   --latest                     If true, download the latest successful build
   --output value, -o value     If set, the build is written to this directory instead
   
Examples

Download a specific build.

unity-cb-tool builds download -t windows-x64 -b 30 -o Builds/

---

Downloading to: Builds/second-wind-interactive-dntm-windows-x64-30.zip
Download complete.

Download the latest build for a target.

unity-cb-tool builds download -t macos --latest -o Builds/

---

Latest build is #22.
Downloading to: Builds/second-wind-interactive-dntm-macos-22.zip
Download complete.

Download the latest build for a target and unzip its contents.

unity-cb-tool builds download -t windows-x64 --latest -o Builds/ --unzip

---

Latest build is #30.
Downloading to: /tmp/second-wind-interactive-dntm-windows-x64-30.zip124929410
Download complete.
Unzipping content to: Builds/
Writing: Builds/DNTM.exe
Writing: Builds/DNTM_Data/app.info
Writing: Builds/DNTM_Data/boot.config
Writing: Builds/DNTM_Data/globalgamemanagers
Writing: Builds/DNTM_Data/globalgamemanagers.assets
Writing: Builds/DNTM_Data/level0
Writing: Builds/DNTM_Data/level1
Writing: Builds/DNTM_Data/level2
Writing: Builds/DNTM_Data/level3

(truncated)
builds wait-for-complete

Wait for builds to complete. If any build fails or is canceled the exit code will be 1.

NAME:
   unity-cb-tool builds wait-for-complete - Wait for in-progress build(s) to finish

USAGE:
   unity-cb-tool builds wait-for-complete [command options] [arguments...]

OPTIONS:
   --target-id value, -t value  Build target ID
   --build value, -b value      Build number for build target (default: -1)
   --all                        If true, wait for all active builds for all enabled targets
   --abort-on-fail              If true, and --all is specified, exit as soon as one build fails or is canceled.
Examples

Wait for a single build to finish.

unity-cb-tool builds wait-for-complete -t windows-x64 -b 8 

---

Watching: windows-x64 #8
Build: windows-x64 #8 status changed from sentToBuilder to started

(...time elapses)

Build: windows-x64 #8 status changed from started to success
Build: windowx-x64 #8 finished.
Build(s) complete.

Wait for the latest build for a target to finish.

unity-cb-tool builds wait-for-complete -t windows-x64

---

Watching: windows-x64 #9
Build: windows-x64 #9 status changed from sentToBuilder to started

(...time elapses)

Build: windows-x64 #9 status changed from started to success
Build: windowx-x64 #9 finished.
Build(s) complete.

Wait for the latest builds in all enabled targets to finish.

unity-cb-tool builds wait-for-complete --all

---

Watching: windows-x64 #9
Watching: macos #4
Build: macos #4 status changed from sentToBuilder to started
Build: windows-x64 #9 status changed from sentToBuilder to started

(...time elapses)

Build: macos #4 status changed from started to success.
Build: macos #4 finished.

(...time elapses)

Build: windows-x64 #9 status changed from started to success
Build: windows-x64 #9 finished.
Build(s) complete.

Wait for the latest builds in all enabled targets to finish, and abort if any one of them fails for any reason.

unity-cb-tool builds wait-for-complete --all --abort-on-fail

---

Watching: windows-x64 #13
Watching: macos #9
Build: macos #9 status changed from sentToBuilder to started
Build: windows-x64 #13 status changed from sentToBuilder to started

(...time elapses)

Build: macos #9 status changed from started to failure
Build: macos #9 failed with status: failure
Aborting early, build: macos #9 failed with status: canceled
git head

Prints info about the current commit, if a Git repo is found in the current directory or any parent directory.

NAME:
   unity-cb-tool git head - Output current revision and commit message for HEAD

USAGE:
   unity-cb-tool git head [command options] [arguments...]

OPTIONS:
   --repo-path value, -p value  If set, search for Git repo there instead of current working directory
Example
unity-cb-tool git head

---

Revision: d1396dfaddbaf0b9294d3b7509bd6ae8fc2a18fd
Message:  Committed some stuff.

git build-matches-head

Checks if builds match the current HEAD revision. Exit code 1 is returned if any build does not match.

NAME:
   unity-cb-tool git build-matches-head - Determine if the build(s) match the current HEAD revision

USAGE:
   unity-cb-tool git build-matches-head [command options] [arguments...]

OPTIONS:
   --target-id value, -t value  Build target ID
   --build value, -b value      Build number for build target (default: -1)
   --all                        If true, check if all enabled targets match
   --repo-path value, -p value  If set, search for Git repo there instead of current working directory
Examples

Check if a specific build matches.

unity-cb-tool git build-matches-head -t windows-x64 -b 1

---

HEAD: 82eee0b975ede2c4b71b780fb77ca2987b830ec0
Build windows-x64 #1 matches HEAD.

Check if a specific build matches (it doesn't).

unity-cb-tool git build-matches-head -t windows-x64 -b 4

---

HEAD: 82eee0b975ede2c4b71b780fb77ca2987b830ec0
Build windows-x64 #4 is revision 324dfs3f, head is 82eee0b9
Build(s) do not match.

Check if latest build for a target matches.

unity-cb-tool git build-matches-head -t windows-x64

---

HEAD: 82eee0b975ede2c4b71b780fb77ca2987b830ec0
Build windows-x64 #19 matches HEAD.

Check if all latest builds for all enabled targets match.

unity-cb-tool git build-matches-head --all

---

HEAD: 82eee0b975ede2c4b71b780fb77ca2987b830ec0
Build windows-x64 #13 matches HEAD.
Build macos #10 matches HEAD.

Check if all latest builds for all enabled targets match (one target missing build).

unity-cb-tool git build-matches-head --all

---

HEAD: 82eee0b975ede2c4b71b780fb77ca2987b830ec0
Target default-linux-desktop-universal does not have a successful build.
Build windows-x64 #13 matches HEAD.
Build macos #10 matches HEAD.
Build(s) do not match.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RateLimitedError = fmt.Errorf("API rate limit reached")
View Source
var ResourceNotFoundError = fmt.Errorf("Resource not found")

Functions

func Builds_Cancel

func Builds_Cancel(context *CloudBuildContext, buildTargetId string, buildNumber int64) error

func Builds_CancelAll

func Builds_CancelAll(context *CloudBuildContext, buildTargetId string) error

func Builds_Download added in v0.2.0

func Builds_Download(context *CloudBuildContext, buildTargetId string, buildNumber int64, latest bool, outputDir string, unzip bool) error

func Builds_Latest

func Builds_Latest(context *CloudBuildContext, onlySuccess bool, onlyEnabled bool) (map[string]*Build, error)

func Builds_WaitForComplete added in v0.2.2

func Builds_WaitForComplete(context *CloudBuildContext, buildTargetId string, buildNumber int64, all bool, abortOnFail bool) error

func FatalIfError added in v0.2.3

func FatalIfError(err error)

func Git_BuildsMatchHead added in v0.2.2

func Git_BuildsMatchHead(context *CloudBuildContext, repoPath string, buildTargetId string, buildNumber int64, all bool) (bool, error)

func IsBuildActive added in v0.2.2

func IsBuildActive(build *Build) bool

Types

type Artifact

type Artifact struct {
	Files []File `json:"files,omitempty"`
	Key   string `json:"key"`
	Name  string `json:"name"`
}

type Build

type Build struct {
	Number            int           `json:"build"`
	TargetId          string        `json:"buildTargetId"`
	TargetName        string        `json:"buildTargetName"`
	GUID              string        `json:"buildGUID,omitempty"` // NOTE: On unfinished builds this is empty!
	Created           time.Time     `json:"created"`
	Status            string        `json:"buildStatus"`
	Finished          time.Time     `json:"finished"`
	Platform          string        `json:"platform"`
	TotalTimeSeconds  float64       `json:"totalTimeInSeconds"`
	BuildTimeSeconds  float64       `json:"buildTimeInSeconds"`
	Links             Links         `json:"links"`
	ScmBranch         string        `json:"scmBranch"`
	LastBuiltRevision string        `json:"lastBuiltRevision,omitempty"`
	Changesets        []interface{} `json:"changeset,omitempty"`
	UnityVersion      string        `json:"unityVersion"`
}

func Builds_List

func Builds_List(context *CloudBuildContext, buildTargetId string, filterStatus string, filterPlatform string, limit int64) ([]Build, error)

func Builds_Status added in v0.2.0

func Builds_Status(context *CloudBuildContext, buildTargetId string, buildNumber int64) (*Build, error)

func (*Build) UniqueId added in v0.2.2

func (b *Build) UniqueId() string

type BuildAttempt

type BuildAttempt struct {
	Build
	FailureDetails interface{} `json:"failureDetails,omitempty"`
	Error          string      `json:"error,omitempty"`
}

func Builds_Start

func Builds_Start(context *CloudBuildContext, buildTargetId string, clean bool) (*BuildAttempt, error)

func Builds_StartAll

func Builds_StartAll(context *CloudBuildContext, clean bool) ([]BuildAttempt, error)

type BuildTarget

type BuildTarget struct {
	Name     string               `json:"name"`
	Platform string               `json:"platform"`
	Id       string               `json:"buildtargetid"`
	Enabled  bool                 `json:"enabled"`
	Builds   []Build              `json:"builds,omitempty"`
	Settings *BuildTargetSettings `json:"settings,omitempty"`
}

func Targets_List

func Targets_List(context *CloudBuildContext) ([]BuildTarget, error)

type BuildTargetSettings

type BuildTargetSettings struct {
	AutoBuild      bool   `json:"autoBuild"`
	ExecutableName string `json:"executablename"`
	Scm            struct {
		Branch       string `json:"branch"`
		Subdirectory string `json:"subdirectory,omitempty"`
		Type         string `json:"type"`
	} `json:"scm"`
	UnityVersion string      `json:"unityVersion"`
	Advanced     interface{} `json:"advanced,omitempty"`
}

type Changeset

type Changeset struct {
}

type CloudBuildContext

type CloudBuildContext struct {
	OrgId        string       `json:"orgid"`
	ProjectId    string       `json:"projectid"`
	ApiKey       string       `json:"apikey"`
	OutputFormat OutputFormat `json:"outputformat"`
	Verbose      bool
}

type File

type File struct {
	Filename string `json:"filename"`
	Href     string `json:"href"`
	Size     int64  `json:"size"`
}

type GitCommit added in v0.2.2

type GitCommit struct {
	Revision string `json:"revision"`
	Message  string `json:"message,omitempty"`
}

func Git_Head added in v0.2.2

func Git_Head(context *CloudBuildContext, repoPath string) (*GitCommit, error)
type Link struct {
	Method string `json:"method"`
	Href   string `json:"href"`
	Meta   struct {
		Type string `json:"type,omitempty"`
	} `json:"meta"`
}
type Links struct {
	Artifacts       []Artifact `json:"artifacts,omitempty"`
	Self            *Link      `json:"self,omitempty"`
	Log             *Link      `json:"log,omitempty"`
	AuditLog        *Link      `json:"auditlog,omitempty"`
	DownloadPrimary *Link      `json:"download_primary,omitempty"`
}

type OutputFormat

type OutputFormat int
const (
	OutputFormat_None OutputFormat = iota
	OutputFormat_JSON
	OutputFormat_Human
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL