当前位置: 首页>>代码示例>>Golang>>正文


Golang Buildfile.WriteCmdSilent方法代码示例

本文整理汇总了Golang中github.com/voxxit/drone/shared/build/buildfile.Buildfile.WriteCmdSilent方法的典型用法代码示例。如果您正苦于以下问题:Golang Buildfile.WriteCmdSilent方法的具体用法?Golang Buildfile.WriteCmdSilent怎么用?Golang Buildfile.WriteCmdSilent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/voxxit/drone/shared/build/buildfile.Buildfile的用法示例。


在下文中一共展示了Buildfile.WriteCmdSilent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Write

func (b *Bintray) Write(f *buildfile.Buildfile) {
	var cmd string

	// Validate Username, ApiKey, Packages
	if len(b.Username) == 0 || len(b.ApiKey) == 0 || len(b.Packages) == 0 {
		f.WriteCmdSilent(`echo -e "Bintray Plugin: Missing argument(s)\n\n"`)

		if len(b.Username) == 0 {
			f.WriteCmdSilent(`echo -e "\tusername not defined in yaml config"`)
		}

		if len(b.ApiKey) == 0 {
			f.WriteCmdSilent(`echo -e "\tapi_key not defined in yaml config"`)
		}

		if len(b.Packages) == 0 {
			f.WriteCmdSilent(`echo -e "\tpackages not defined in yaml config"`)
		}

		f.WriteCmdSilent("exit 1")

		return
	}

	for _, pkg := range b.Packages {
		pkg.Write(b.Username, b.ApiKey, f)
	}

	f.WriteCmd(cmd)

}
开发者ID:voxxit,项目名称:drone,代码行数:31,代码来源:bintray.go

示例2: Write

func (m *Marathon) Write(f *buildfile.Buildfile) {
	// debugging purposes so we can see if / where something is failing
	f.WriteCmdSilent("echo 'deploying to Marathon ...'")

	post := fmt.Sprintf(
		"curl -X POST -d @%s http://%s/v2/apps --header \"Content-Type:application/json\"",
		m.ConfigFile,
		m.Host,
	)
	f.WriteCmdSilent(post)
}
开发者ID:voxxit,项目名称:drone,代码行数:11,代码来源:marathon.go

示例3: Write

func (p *PyPI) Write(f *buildfile.Buildfile) {
	var indexServer string
	var repository string

	if len(p.Username) == 0 || len(p.Password) == 0 {
		// nothing to do if the config is fundamentally flawed
		return
	}

	// Handle the setting a custom pypi server/repository
	if len(p.Repository) == 0 {
		indexServer = "pypi"
		repository = ""
	} else {
		indexServer = "custom"
		repository = fmt.Sprintf("repository:%s", p.Repository)
	}

	f.WriteCmdSilent("echo 'publishing to PyPI...'")

	// find the setup.py file
	f.WriteCmdSilent("_PYPI_SETUP_PY=$(find . -name 'setup.py')")

	// build the .pypirc file that pypi expects
	f.WriteCmdSilent(fmt.Sprintf(pypirc, indexServer, indexServer, p.Username, p.Password, repository))
	formatStr := p.BuildFormatStr()

	// if we found the setup.py file use it to deploy
	f.WriteCmdSilent(fmt.Sprintf(deployCmd, formatStr, indexServer))
}
开发者ID:voxxit,项目名称:drone,代码行数:30,代码来源:pypi.go

示例4: Write

func (s *Swift) Write(f *buildfile.Buildfile) {
	var target string
	// All options are required, so ensure they are present
	if len(s.Username) == 0 || len(s.Password) == 0 || len(s.AuthURL) == 0 || len(s.Region) == 0 || len(s.Source) == 0 || len(s.Container) == 0 {
		f.WriteCmdSilent(`echo "Swift: Missing argument(s)"`)
		return
	}

	// If a target was provided, prefix it with a /
	if len(s.Target) > 0 {
		target = fmt.Sprintf("/%s", strings.TrimPrefix(s.Target, "/"))
	}

	// debugging purposes so we can see if / where something is failing
	f.WriteCmdSilent(`echo "Swift: Publishing..."`)

	// install swiftly using PIP
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] || pip install swiftly 1> /dev/null 2> /dev/null")
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo pip install swiftly 1> /dev/null 2> /dev/null")

	// Write out environment variables
	f.WriteEnv("SWIFTLY_AUTH_URL", s.AuthURL)
	f.WriteEnv("SWIFTLY_AUTH_USER", s.Username)
	f.WriteEnv("SWIFTLY_AUTH_KEY", s.Password)
	f.WriteEnv("SWIFTLY_REGION", s.Region)

	f.WriteCmd(fmt.Sprintf(`swiftly put -i %s %s%s`, s.Source, s.Container, target))
}
开发者ID:voxxit,项目名称:drone,代码行数:28,代码来源:swift.go

示例5: Write

func (n *Nodejitsu) Write(f *buildfile.Buildfile) {
	if len(n.Token) == 0 || len(n.User) == 0 {
		return
	}

	f.WriteEnv("username", n.User)
	f.WriteEnv("apiToken", n.Token)

	// Install the jitsu command line interface then
	// deploy the configured app.
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] || npm install -g jitsu")
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo npm install -g jitsu")
	f.WriteCmd("jitsu deploy")
}
开发者ID:voxxit,项目名称:drone,代码行数:14,代码来源:nodejitsu.go

示例6: Write

func (d *Dropbox) Write(f *buildfile.Buildfile) {

	if len(d.AccessToken) == 0 || len(d.Source) == 0 || len(d.Target) == 0 {
		return
	}
	if strings.HasPrefix(d.Target, "/") {
		d.Target = d.Target[1:]
	}

	f.WriteCmdSilent("echo 'publishing to Dropbox ...'")

	cmd := "curl --upload-file %s -H \"Authorization: Bearer %s\" \"https://api-content.dropbox.com/1/files_put/auto/%s?overwrite=true\""
	f.WriteCmd(fmt.Sprintf(cmd, d.Source, d.AccessToken, d.Target))

}
开发者ID:voxxit,项目名称:drone,代码行数:15,代码来源:dropbox.go

示例7: Write

func (g *Git) Write(f *buildfile.Buildfile) {
	f.WriteCmdSilent(CmdRevParse)
	f.WriteCmdSilent(CmdGlobalUser)
	f.WriteCmdSilent(CmdGlobalEmail)

	// add target as a git remote
	f.WriteCmd(fmt.Sprintf("git remote add deploy %s", g.Target))

	dest := g.Branch
	if len(dest) == 0 {
		dest = "master"
	}

	switch g.Force {
	case true:
		// this is useful when the there are artifacts generated
		// by the build script, such as less files converted to css,
		// that need to be deployed to git remote.
		f.WriteCmd(fmt.Sprintf("git add -A"))
		f.WriteCmd(fmt.Sprintf("git commit -m 'add build artifacts'"))
		f.WriteCmd(fmt.Sprintf("git push deploy HEAD:%s --force", dest))
	case false:
		// otherwise we just do a standard git push
		f.WriteCmd(fmt.Sprintf("git push deploy $COMMIT:%s", dest))
	}
}
开发者ID:voxxit,项目名称:drone,代码行数:26,代码来源:git.go

示例8: Write

func (cf *CloudFoundry) Write(f *buildfile.Buildfile) {
	downloadCmd := "curl -sLO http://go-cli.s3-website-us-east-1.amazonaws.com/releases/latest/cf-cli_amd64.deb"
	installCmd := "dpkg -i cf-cli_amd64.deb 1> /dev/null 2> /dev/null"

	// download and install the cf tool
	f.WriteCmdSilent(fmt.Sprintf("[ -f /usr/bin/sudo ] && sudo %s || %s", downloadCmd, downloadCmd))
	f.WriteCmdSilent(fmt.Sprintf("[ -f /usr/bin/sudo ] && sudo %s || %s", installCmd, installCmd))

	// login
	loginCmd := "cf login -a %s -u %s -p %s"

	organization := cf.Org
	if organization != "" {
		loginCmd += fmt.Sprintf(" -o %s", organization)
	}

	space := cf.Space
	if space != "" {
		loginCmd += fmt.Sprintf(" -s %s", space)
	}

	f.WriteCmdSilent(fmt.Sprintf(loginCmd, cf.Target, cf.Username, cf.Password))

	// push app
	pushCmd := "cf push %s"
	f.WriteCmd(fmt.Sprintf(pushCmd, cf.App))
}
开发者ID:voxxit,项目名称:drone,代码行数:27,代码来源:cloudfoundry.go

示例9: Write

func (n *NPM) Write(f *buildfile.Buildfile) {
	// If the yaml doesn't provide a username or password
	// we should attempt to use the global defaults.
	if len(n.Email) == 0 ||
		len(n.Username) == 0 ||
		len(n.Password) == 0 {
		n.Username = *DefaultUser
		n.Password = *DefaultPass
		n.Email = *DefaultEmail
	}

	// If the yaml doesn't provide a username or password,
	// and there was not global configuration defined, EXIT.
	if len(n.Email) == 0 ||
		len(n.Username) == 0 ||
		len(n.Password) == 0 {
		return
	}

	// Setup the npm credentials
	f.WriteCmdSilent(fmt.Sprintf(CmdLogin, n.Username, n.Password, n.Email))

	// Setup custom npm registry
	if len(n.Registry) != 0 {
		f.WriteCmd(fmt.Sprintf(CmdSetRegistry, n.Registry))
	}

	// Set npm to always authenticate
	if n.AlwaysAuth {
		f.WriteCmd(CmdAlwaysAuth)
	}

	if len(n.Folder) == 0 {
		n.Folder = "."
	}

	f.WriteString(fmt.Sprintf(CmdPublish, n.Folder, n.Tag, n.Folder))
}
开发者ID:voxxit,项目名称:drone,代码行数:38,代码来源:npm.go

示例10: Write

func (h *Heroku) Write(f *buildfile.Buildfile) {
	f.WriteCmdSilent(CmdRevParse)
	f.WriteCmdSilent(CmdGlobalUser)
	f.WriteCmdSilent(CmdGlobalEmail)
	f.WriteCmdSilent(fmt.Sprintf(CmdLogin, h.Token))

	// add heroku as a git remote
	f.WriteCmd(fmt.Sprintf("git remote add heroku https://git.heroku.com/%s.git", h.App))

	switch h.Force {
	case true:
		// this is useful when the there are artifacts generated
		// by the build script, such as less files converted to css,
		// that need to be deployed to Heroku.
		f.WriteCmd(fmt.Sprintf("git add -A"))
		f.WriteCmd(fmt.Sprintf("git commit -m 'adding build artifacts'"))
		f.WriteCmd(fmt.Sprintf("git push heroku HEAD:refs/heads/master --force"))
	case false:
		// otherwise we just do a standard git push
		f.WriteCmd(fmt.Sprintf("git push heroku $COMMIT:refs/heads/master"))
	}
}
开发者ID:voxxit,项目名称:drone,代码行数:22,代码来源:heroku.go

示例11: Write

func (s *S3) Write(f *buildfile.Buildfile) {

	// skip if AWS key or SECRET are empty. A good example for this would
	// be forks building a project. S3 might be configured in the source
	// repo, but not in the fork
	if len(s.Key) == 0 || len(s.Secret) == 0 {
		return
	}

	// debugging purposes so we can see if / where something is failing
	f.WriteCmdSilent("echo 'publishing to Amazon S3 ...'")

	// install the AWS cli using PIP
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] || pip install awscli 1> /dev/null 2> /dev/null")
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo pip install awscli 1> /dev/null 2> /dev/null")

	f.WriteEnv("AWS_ACCESS_KEY_ID", s.Key)
	f.WriteEnv("AWS_SECRET_ACCESS_KEY", s.Secret)

	// make sure a default region is set
	if len(s.Region) == 0 {
		s.Region = "us-east-1"
	}

	// make sure a default access is set
	// let's be conservative and assume private
	if len(s.Access) == 0 {
		s.Access = "private"
	}

	// if the target starts with a "/" we need
	// to remove it, otherwise we might adding
	// a 3rd slash to s3://
	if strings.HasPrefix(s.Target, "/") {
		s.Target = s.Target[1:]
	}

	switch s.Recursive {
	case true:
		f.WriteCmd(fmt.Sprintf(`aws s3 cp %s s3://%s/%s --recursive --acl %s --region %s`, s.Source, s.Bucket, s.Target, s.Access, s.Region))
	case false:
		f.WriteCmd(fmt.Sprintf(`aws s3 cp %s s3://%s/%s --acl %s --region %s`, s.Source, s.Bucket, s.Target, s.Access, s.Region))
	}
}
开发者ID:voxxit,项目名称:drone,代码行数:44,代码来源:s3.go

示例12: Write

func (a *Azure) Write(f *buildfile.Buildfile) {
	if len(a.StorageAccount) == 0 || len(a.StorageAccessKey) == 0 || len(a.StorageContainer) == 0 || len(a.Source) == 0 {
		return
	}

	f.WriteCmdSilent("echo 'publishing to Azure Storage ...'")

	// install Azure xplat CLI
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] || npm install -g azure-cli 1> /dev/null 2> /dev/null")
	f.WriteCmdSilent("[ -f /usr/bin/sudo ] && sudo npm install -g azure-cli 1> /dev/null 2> /dev/null")

	f.WriteEnv("AZURE_STORAGE_ACCOUNT", a.StorageAccount)
	f.WriteEnv("AZURE_STORAGE_ACCESS_KEY", a.StorageAccessKey)

	// if target isn't specified, set to source
	if len(a.Target) == 0 {
		a.Target = a.Source
	}

	f.WriteCmd(fmt.Sprintf(`azure storage blob upload --container %s %s %s`, a.StorageContainer, a.Source, a.Target))
}
开发者ID:voxxit,项目名称:drone,代码行数:21,代码来源:azure.go

示例13: Write

func (t *Tsuru) Write(f *buildfile.Buildfile) {
	f.WriteCmdSilent(CmdRevParse)
	f.WriteCmdSilent(CmdGlobalUser)
	f.WriteCmdSilent(CmdGlobalEmail)

	// add tsuru as a git remote
	f.WriteCmd(fmt.Sprintf("git remote add tsuru %s", t.Remote))

	switch t.Force {
	case true:
		// this is useful when the there are artifacts generated
		// by the build script, such as less files converted to css,
		// that need to be deployed to Tsuru.
		f.WriteCmd(fmt.Sprintf("git add -A"))
		f.WriteCmd(fmt.Sprintf("git commit -m 'adding build artifacts'"))
		f.WriteCmd(fmt.Sprintf("git push tsuru HEAD:master --force"))
	case false:
		// otherwise we just do a standard git push
		f.WriteCmd(fmt.Sprintf("git push tsuru $COMMIT:master"))
	}
}
开发者ID:voxxit,项目名称:drone,代码行数:21,代码来源:tsuru.go

示例14: Write

func (h *Deis) Write(f *buildfile.Buildfile) {
	f.WriteCmdSilent(CmdRevParse)
	f.WriteCmdSilent(CmdGlobalUser)
	f.WriteCmdSilent(CmdGlobalEmail)

	// [email protected]:2222/drone.git

	f.WriteCmd(fmt.Sprintf("git remote add deis ssh://[email protected]%s%s.git", h.Deisurl, h.App))

	switch h.Force {
	case true:
		// this is useful when the there are artifacts generated
		// by the build script, such as less files converted to css,
		// that need to be deployed to Deis.
		f.WriteCmd(fmt.Sprintf("git add -A"))
		f.WriteCmd(fmt.Sprintf("git commit -m 'adding build artifacts'"))
		f.WriteCmd(fmt.Sprintf("git push deis HEAD:master --force"))
	case false:
		// otherwise we just do a standard git push
		f.WriteCmd(fmt.Sprintf("git push deis $COMMIT:master"))
	}
}
开发者ID:voxxit,项目名称:drone,代码行数:22,代码来源:deis.go

示例15: createGitArchive

func createGitArchive(f *buildfile.Buildfile) bool {
	f.WriteEnv("COMMIT", "$(git rev-parse HEAD)")
	f.WriteEnv("ARTIFACT", "${PWD##*/}-${COMMIT}.tar.gz")
	f.WriteCmdSilent("git archive --format=tar.gz --prefix=${PWD##*/}/ ${COMMIT} > ${ARTIFACT}")
	return true
}
开发者ID:voxxit,项目名称:drone,代码行数:6,代码来源:ssh.go


注:本文中的github.com/voxxit/drone/shared/build/buildfile.Buildfile.WriteCmdSilent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。