build

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// These flags override values in build env.
	GitCommitFlag   = flag.String("git-commit", "", `Overrides git commit hash embedded into executables`)
	GitBranchFlag   = flag.String("git-branch", "", `Overrides git branch being built`)
	GitTagFlag      = flag.String("git-tag", "", `Overrides git tag being built`)
	BuildnumFlag    = flag.String("buildnum", "", `Overrides CI build number`)
	PullRequestFlag = flag.Bool("pull-request", false, `Overrides pull request status of the build`)
	CronJobFlag     = flag.Bool("cron-job", false, `Overrides cron job status of the build`)
)
View Source
var DryRunFlag = flag.Bool("n", false, "dry run, don't execute commands")

Functions

func CopyFile

func CopyFile(dst, src string, mode os.FileMode)

CopyFile copies a file.

func ExpandPackagesNoVendor

func ExpandPackagesNoVendor(patterns []string) []string

ExpandPackagesNoVendor expands a cmd/go import path pattern, skipping vendored packages.

func GOPATH

func GOPATH() string

GOPATH returns the value that the GOPATH environment variable should be set to.

func GoTool

func GoTool(tool string, args ...string) *exec.Cmd

GoTool returns the command that runs a go tool. This uses go from GOROOT instead of PATH so that go commands executed by build use the same version of Go as the 'host' that runs build code. e.g.

/usr/lib/go-1.11/bin/go run build/ci.go ...

runs using go 1.11 and invokes go 1.11 tools from the same GOROOT. This is also important because runtime.Version checks on the host should match the tools that are run.

func MustRun

func MustRun(cmd *exec.Cmd)

MustRun executes the given command and exits the host process for any error.

func MustRunCommand

func MustRunCommand(cmd string, args ...string)

func RunGit

func RunGit(args ...string) string

RunGit runs a git subcommand and returns its output. The command must complete successfully.

func UploadSFTP added in v1.1.0

func UploadSFTP(identityFile, host, dir string, files []string) error

UploadSFTP uploads files to a remote host using the sftp command line tool. The destination host may be specified either as [user@]host[: or as a URI in the form sftp://[user@]host[:port].

Types

type Environment

type Environment struct {
	Name                string // name of the environment
	Repo                string // name of GitHub repo
	Commit, Branch, Tag string // Git info
	Buildnum            string
	IsPullRequest       bool
	IsCronJob           bool
}

Environment contains metadata provided by the build environment.

func Env

func Env() Environment

Env returns metadata about the current CI environment, falling back to LocalEnv if not running on CI.

func LocalEnv

func LocalEnv() Environment

LocalEnv returns build environment metadata gathered from git.

func (Environment) String

func (env Environment) String() string

Jump to

Keyboard shortcuts

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