本文整理汇总了Golang中github.com/bitrise-io/go-utils/cmdex.CopyFile函数的典型用法代码示例。如果您正苦于以下问题:Golang CopyFile函数的具体用法?Golang CopyFile怎么用?Golang CopyFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CopyFile函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: saveRawOutputToLogFile
func saveRawOutputToLogFile(rawXcodebuildOutput string, isRunSuccess bool) error {
tmpDir, err := pathutil.NormalizedOSTempDirPath("xcodebuild-output")
if err != nil {
return fmt.Errorf("Failed to create temp dir, error: %s", err)
}
logFileName := "raw-xcodebuild-output.log"
logPth := filepath.Join(tmpDir, logFileName)
if err := fileutil.WriteStringToFile(logPth, rawXcodebuildOutput); err != nil {
return fmt.Errorf("Failed to write xcodebuild output to file, error: %s", err)
}
if !isRunSuccess {
deployDir := os.Getenv("BITRISE_DEPLOY_DIR")
if deployDir == "" {
return errors.New("No BITRISE_DEPLOY_DIR found")
}
deployPth := filepath.Join(deployDir, logFileName)
if err := cmdex.CopyFile(logPth, deployPth); err != nil {
return fmt.Errorf("Failed to copy xcodebuild output log file from (%s) to (%s), error: %s", logPth, deployPth, err)
}
logPth = deployPth
}
if err := cmd.ExportEnvironmentWithEnvman("BITRISE_XCODE_RAW_TEST_RESULT_TEXT_PATH", logPth); err != nil {
log.Warn("Failed to export: BITRISE_XCODE_RAW_TEST_RESULT_TEXT_PATH, error: %s", err)
}
return nil
}
开发者ID:bitrise-io,项目名称:steps-xcode-test,代码行数:29,代码来源:main.go
示例2: ExportOutputFile
// ExportOutputFile ...
func ExportOutputFile(sourcePth, destinationPth, envKey string) error {
if sourcePth != destinationPth {
if err := cmdex.CopyFile(sourcePth, destinationPth); err != nil {
return err
}
}
return exportEnvironmentWithEnvman(envKey, destinationPth)
}
开发者ID:bitrise-io,项目名称:steps-xcode-archive,代码行数:10,代码来源:export.go
示例3: downloadPluginBin
func downloadPluginBin(sourceURL, destinationPth string) error {
url, err := url.Parse(sourceURL)
if err != nil {
return fmt.Errorf("failed to parse url (%s), error: %s", sourceURL, err)
}
// Download local binary
if url.Scheme == "file" {
src := strings.Replace(sourceURL, url.Scheme+"://", "", -1)
if err := cmdex.CopyFile(src, destinationPth); err != nil {
return fmt.Errorf("failed to copy (%s) to (%s)", src, destinationPth)
}
return nil
}
// Download remote binary
out, err := os.Create(destinationPth)
defer func() {
if err := out.Close(); err != nil {
log.Warnf("failed to close (%s)", destinationPth)
}
}()
if err != nil {
return fmt.Errorf("failed to create (%s), error: %s", destinationPth, err)
}
resp, err := http.Get(sourceURL)
if err != nil {
return fmt.Errorf("failed to download from (%s), error: %s", sourceURL, err)
}
defer func() {
if err := resp.Body.Close(); err != nil {
log.Warnf("failed to close (%s) body", sourceURL)
}
}()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("non success status code (%d)", resp.StatusCode)
}
_, err = io.Copy(out, resp.Body)
if err != nil {
return fmt.Errorf("failed to download from (%s), error: %s", sourceURL, err)
}
return nil
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:49,代码来源:install.go
示例4: setup
func setup(c *cli.Context) error {
log.Debug("Setup")
// Input validation
steplibURI := c.String(CollectionKey)
if steplibURI == "" {
log.Fatal("No step collection specified")
}
copySpecJSONPath := c.String(CopySpecJSONKey)
if c.IsSet(LocalCollectionKey) {
log.Warn("'local' flag is deprecated")
log.Warn("use 'file://' prefix in steplib path instead")
fmt.Println()
}
if c.Bool(LocalCollectionKey) {
if !strings.HasPrefix(steplibURI, "file://") {
log.Warnf("Appending file path prefix (file://) to StepLib (%s)", steplibURI)
steplibURI = "file://" + steplibURI
log.Warnf("From now you can refer to this StepLib with URI: %s", steplibURI)
log.Warnf("For example, to delete StepLib call: `stepman delete --collection %s`", steplibURI)
}
}
// Setup
if err := setupSteplib(steplibURI, false); err != nil {
log.Fatalf("Setup failed, error: %s", err)
}
// Copy spec.json
if copySpecJSONPath != "" {
log.Infof("Copying spec YML to path: %s", copySpecJSONPath)
route, found := stepman.ReadRoute(steplibURI)
if !found {
log.Fatalf("No route found for steplib (%s)", steplibURI)
}
sourceSpecJSONPth := stepman.GetStepSpecPath(route)
if err := cmdex.CopyFile(sourceSpecJSONPth, copySpecJSONPath); err != nil {
log.Fatalf("Failed to copy spec.json from (%s) to (%s), error: %s", sourceSpecJSONPth, copySpecJSONPath, err)
}
}
return nil
}
开发者ID:godrei,项目名称:stepman,代码行数:48,代码来源:setup.go
示例5: setup
func setup(c *cli.Context) {
log.Debug("Setup")
// Input validation
steplibURI := c.String(CollectionKey)
if steplibURI == "" {
log.Fatal("No step collection specified")
}
copySpecJSONPath := c.String(CopySpecJSONKey)
if c.IsSet(LocalCollectionKey) {
log.Warn("'local' flag is deprecated")
log.Warn("use 'file://' suffix in steplib path instead")
fmt.Println()
}
if c.Bool(LocalCollectionKey) {
if !strings.HasPrefix(steplibURI, "file://") {
steplibURI = "file://" + steplibURI
}
}
// Setup
if err := setupSteplib(steplibURI, false); err != nil {
log.Fatalf("Steup failed, error: %s", err)
}
// Copy spec.json
if copySpecJSONPath != "" {
log.Infof("Copying spec YML to path: %s", copySpecJSONPath)
route, found := stepman.ReadRoute(steplibURI)
if !found {
log.Fatalf("No route found for steplib (%s)", steplibURI)
}
sourceSpecJSONPth := stepman.GetStepSpecPath(route)
if err := cmdex.CopyFile(sourceSpecJSONPth, copySpecJSONPath); err != nil {
log.Fatalf("Failed to copy spec.json from (%s) to (%s), error: %s", sourceSpecJSONPth, copySpecJSONPath, err)
}
}
}
开发者ID:viktorbenei,项目名称:stepman,代码行数:43,代码来源:setup.go
示例6: activate
//.........这里部分代码省略.........
if !stepFound {
if !update {
if version == "" {
log.Fatalf("[STEPMAN] - Collection doesn't contain any version of step (id:%s)", id)
} else {
log.Fatalf("[STEPMAN] - Collection doesn't contain step (id:%s) (version:%s)", id, version)
}
}
if version == "" {
log.Infof("[STEPMAN] - Collection doesn't contain any version of step (id:%s) -- Updating StepLib", id)
} else {
log.Infof("[STEPMAN] - Collection doesn't contain step (id:%s) (version:%s) -- Updating StepLib", id, version)
}
collection, err = updateCollection(collectionURI)
if err != nil {
log.Fatalf("Failed to update collection (%s), err: %s", collectionURI, err)
}
_, stepFound := collection.GetStep(id, version)
if !stepFound {
if version != "" {
log.Fatalf("[STEPMAN] - Even the updated collection doesn't contain step (id:%s) (version:%s)", id, version)
} else {
log.Fatalf("[STEPMAN] - Even the updated collection doesn't contain any version of step (id:%s)", id)
}
}
}
// If version doesn't provided use latest
if version == "" {
log.Debug("[STEPMAN] - Missing step version -- Use latest version")
latest, err := collection.GetLatestStepVersion(id)
if err != nil {
log.Fatal("[STEPMAN] - Failed to get step latest version: ", err)
}
log.Debug("[STEPMAN] - Latest version of step: ", latest)
version = latest
}
// Check step exist in local cache
step, found := collection.GetStep(id, version)
if !found {
log.Fatalf("[STEPMAN] - Collection doesn't contain step (id:%s) (version:%s)", id, version)
}
if step.Source == nil {
log.Fatal("Invalid step, missing Source property")
}
route, found := stepman.ReadRoute(collectionURI)
if !found {
log.Fatalf("No route found for lib: %s", collectionURI)
}
stepCacheDir := stepman.GetStepCacheDirPath(route, id, version)
if exist, err := pathutil.IsPathExists(stepCacheDir); err != nil {
log.Fatal("[STEPMAN] - Failed to check path:", err)
} else if !exist {
log.Debug("[STEPMAN] - Step does not exist, download it")
if err := stepman.DownloadStep(collectionURI, collection, id, version, step.Source.Commit); err != nil {
log.Fatal("[STEPMAN] - Failed to download step:", err)
}
}
// Copy to specified path
srcFolder := stepCacheDir
destFolder := path
if exist, err := pathutil.IsPathExists(destFolder); err != nil {
log.Fatalln("[STEPMAN] - Failed to check path:", err)
} else if !exist {
if err := os.MkdirAll(destFolder, 0777); err != nil {
log.Fatalln("[STEPMAN] - Failed to create path:", err)
}
}
if err = cmdex.CopyDir(srcFolder+"/", destFolder, true); err != nil {
log.Fatalln("[STEPMAN] - Failed to copy step:", err)
}
// Copy step.yml to specified path
if copyYML != "" {
if exist, err := pathutil.IsPathExists(copyYML); err != nil {
log.Fatalln("[STEPMAN] - Failed to check path:", err)
} else if exist {
log.Fatalln("[STEPMAN] - Copy yml destination path exist")
}
stepCollectionDir := stepman.GetStepCollectionDirPath(route, id, version)
stepYMLSrc := stepCollectionDir + "/step.yml"
if err = cmdex.CopyFile(stepYMLSrc, copyYML); err != nil {
log.Fatalln("[STEPMAN] - Failed to copy step.yml:", err)
}
}
return nil
}
开发者ID:bitrise-io,项目名称:stepman,代码行数:101,代码来源:activate.go
示例7: activateAndRunSteps
//.........这里部分代码省略.........
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
stepInfoPtr.ID = stepIDData.IDorURI
if stepInfoPtr.Title == "" {
stepInfoPtr.Title = stepIDData.IDorURI
}
stepInfoPtr.Version = stepIDData.Version
stepInfoPtr.StepLib = stepIDData.SteplibSource
//
// Activating the step
stepDir := configs.BitriseWorkStepsDirPath
stepYMLPth := filepath.Join(configs.BitriseWorkDirPath, "current_step.yml")
if stepIDData.SteplibSource == "path" {
log.Debugf("[BITRISE_CLI] - Local step found: (path:%s)", stepIDData.IDorURI)
stepAbsLocalPth, err := pathutil.AbsPath(stepIDData.IDorURI)
if err != nil {
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
log.Debugln("stepAbsLocalPth:", stepAbsLocalPth, "|stepDir:", stepDir)
if err := cmdex.CopyDir(stepAbsLocalPth, stepDir, true); err != nil {
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
if err := cmdex.CopyFile(filepath.Join(stepAbsLocalPth, "step.yml"), stepYMLPth); err != nil {
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
} else if stepIDData.SteplibSource == "git" {
log.Debugf("[BITRISE_CLI] - Remote step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)
if err := cmdex.GitCloneTagOrBranch(stepIDData.IDorURI, stepDir, stepIDData.Version); err != nil {
if strings.HasPrefix(stepIDData.IDorURI, "[email protected]") {
fmt.Println(colorstring.Yellow(`Note: if the step's repository is an open source one,`))
fmt.Println(colorstring.Yellow(`you should probably use a "https://..." git clone URL,`))
fmt.Println(colorstring.Yellow(`instead of the "[email protected]" git clone URL which usually requires authentication`))
fmt.Println(colorstring.Yellow(`even if the repository is open source!`))
}
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
if err := cmdex.CopyFile(filepath.Join(stepDir, "step.yml"), stepYMLPth); err != nil {
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
} else if stepIDData.SteplibSource == "_" {
log.Debugf("[BITRISE_CLI] - Steplib independent step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)
// Steplib independent steps are completly defined in workflow
stepYMLPth = ""
if err := workflowStep.FillMissingDefaults(); err != nil {
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
开发者ID:godrei,项目名称:bitrise,代码行数:67,代码来源:run_util.go
示例8: removeStepDefaultsAndFillStepOutputs
func removeStepDefaultsAndFillStepOutputs(stepListItem *models.StepListItemModel, defaultStepLibSource string) error {
// Create stepIDData
compositeStepIDStr, workflowStep, err := models.GetStepIDStepDataPair(*stepListItem)
if err != nil {
return err
}
stepIDData, err := models.CreateStepIDDataFromString(compositeStepIDStr, defaultStepLibSource)
if err != nil {
return err
}
// Activate step - get step.yml
tempStepCloneDirPath, err := pathutil.NormalizedOSTempDirPath("step_clone")
if err != nil {
return err
}
tempStepYMLDirPath, err := pathutil.NormalizedOSTempDirPath("step_yml")
if err != nil {
return err
}
tempStepYMLFilePath := filepath.Join(tempStepYMLDirPath, "step.yml")
if stepIDData.SteplibSource == "path" {
stepAbsLocalPth, err := pathutil.AbsPath(stepIDData.IDorURI)
if err != nil {
return err
}
if err := cmdex.CopyFile(filepath.Join(stepAbsLocalPth, "step.yml"), tempStepYMLFilePath); err != nil {
return err
}
} else if stepIDData.SteplibSource == "git" {
if err := cmdex.GitCloneTagOrBranch(stepIDData.IDorURI, tempStepCloneDirPath, stepIDData.Version); err != nil {
return err
}
if err := cmdex.CopyFile(filepath.Join(tempStepCloneDirPath, "step.yml"), tempStepYMLFilePath); err != nil {
return err
}
} else if stepIDData.SteplibSource == "_" {
// Steplib independent steps are completly defined in workflow
tempStepYMLFilePath = ""
} else if stepIDData.SteplibSource != "" {
if err := tools.StepmanSetup(stepIDData.SteplibSource); err != nil {
return err
}
if err := tools.StepmanActivate(stepIDData.SteplibSource, stepIDData.IDorURI, stepIDData.Version, tempStepCloneDirPath, tempStepYMLFilePath); err != nil {
return err
}
} else {
return errors.New("Failed to fill step ouputs: unkown SteplibSource")
}
// Fill outputs
if tempStepYMLFilePath != "" {
specStep, err := ReadSpecStep(tempStepYMLFilePath)
if err != nil {
return err
}
if workflowStep.Title != nil && specStep.Title != nil && *workflowStep.Title == *specStep.Title {
workflowStep.Title = nil
}
if workflowStep.Description != nil && specStep.Description != nil && *workflowStep.Description == *specStep.Description {
workflowStep.Description = nil
}
if workflowStep.Summary != nil && specStep.Summary != nil && *workflowStep.Summary == *specStep.Summary {
workflowStep.Summary = nil
}
if workflowStep.Website != nil && specStep.Website != nil && *workflowStep.Website == *specStep.Website {
workflowStep.Website = nil
}
if workflowStep.SourceCodeURL != nil && specStep.SourceCodeURL != nil && *workflowStep.SourceCodeURL == *specStep.SourceCodeURL {
workflowStep.SourceCodeURL = nil
}
if workflowStep.SupportURL != nil && specStep.SupportURL != nil && *workflowStep.SupportURL == *specStep.SupportURL {
workflowStep.SupportURL = nil
}
workflowStep.PublishedAt = nil
if workflowStep.Source != nil && specStep.Source != nil {
if workflowStep.Source.Git == specStep.Source.Git {
workflowStep.Source.Git = ""
}
if workflowStep.Source.Commit == specStep.Source.Commit {
workflowStep.Source.Commit = ""
}
}
if isStringSliceWithSameElements(workflowStep.HostOsTags, specStep.HostOsTags) {
workflowStep.HostOsTags = []string{}
}
if isStringSliceWithSameElements(workflowStep.ProjectTypeTags, specStep.ProjectTypeTags) {
workflowStep.ProjectTypeTags = []string{}
}
if isStringSliceWithSameElements(workflowStep.TypeTags, specStep.TypeTags) {
workflowStep.TypeTags = []string{}
}
if isDependencySliceWithSameElements(workflowStep.Dependencies, specStep.Dependencies) {
workflowStep.Dependencies = []stepmanModels.DependencyModel{}
}
if workflowStep.IsRequiresAdminUser != nil && specStep.IsRequiresAdminUser != nil && *workflowStep.IsRequiresAdminUser == *specStep.IsRequiresAdminUser {
workflowStep.IsRequiresAdminUser = nil
}
//.........这里部分代码省略.........
开发者ID:bitrise-io,项目名称:bitrise,代码行数:101,代码来源:util.go
示例9: activateAndRunSteps
//.........这里部分代码省略.........
continue
}
stepIDData, err := models.CreateStepIDDataFromString(compositeStepIDStr, defaultStepLibSource)
stepInfoPtr.ID = stepIDData.IDorURI
if workflowStep.Title != nil && *workflowStep.Title != "" {
stepInfoPtr.ID = *workflowStep.Title
}
stepInfoPtr.Version = stepIDData.Version
if err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
stepDir := bitrise.BitriseWorkStepsDirPath
stepYMLPth := path.Join(bitrise.BitriseWorkDirPath, "current_step.yml")
// Activating the step
if stepIDData.SteplibSource == "path" {
log.Debugf("[BITRISE_CLI] - Local step found: (path:%s)", stepIDData.IDorURI)
stepAbsLocalPth, err := pathutil.AbsPath(stepIDData.IDorURI)
if err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
log.Debugln("stepAbsLocalPth:", stepAbsLocalPth, "|stepDir:", stepDir)
if err := cmdex.CopyDir(stepAbsLocalPth, stepDir, true); err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
if err := cmdex.CopyFile(path.Join(stepAbsLocalPth, "step.yml"), stepYMLPth); err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
if len(stepIDData.IDorURI) > 20 {
stepInfoPtr.Version = fmt.Sprintf("path:...%s", stringutil.MaxLastChars(stepIDData.IDorURI, 17))
} else {
stepInfoPtr.Version = fmt.Sprintf("path:%s", stepIDData.IDorURI)
}
} else if stepIDData.SteplibSource == "git" {
log.Debugf("[BITRISE_CLI] - Remote step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)
if err := cmdex.GitCloneTagOrBranch(stepIDData.IDorURI, stepDir, stepIDData.Version); err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
if err := cmdex.CopyFile(path.Join(stepDir, "step.yml"), stepYMLPth); err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
stepInfoPtr.Version = fmt.Sprintf("git:...%s", stringutil.MaxLastChars(stepIDData.IDorURI, 10))
if stepIDData.Version != "" {
stepInfoPtr.Version = stepInfoPtr.Version + "@" + stepIDData.Version
}
} else if stepIDData.SteplibSource == "_" {
log.Debugf("[BITRISE_CLI] - Steplib independent step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)
// Steplib independent steps are completly defined in workflow
stepYMLPth = ""
if err := workflowStep.FillMissingDefaults(); err != nil {
registerStepRunResults("", models.StepRunStatusCodeFailed, 1, err, isLastStep)
开发者ID:bazscsa,项目名称:bitrise-cli,代码行数:67,代码来源:run_util.go
示例10: DownloadPluginFromURL
// DownloadPluginFromURL ....
func DownloadPluginFromURL(URL, dst string) error {
url, err := url.Parse(URL)
if err != nil {
return err
}
scheme := url.Scheme
tokens := strings.Split(URL, "/")
fileName := tokens[len(tokens)-1]
tmpDstFilePath := ""
if scheme != "file" {
OS, arch, err := getOsAndArch()
if err != nil {
return err
}
urlWithSuffix := URL
urlSuffix := fmt.Sprintf("-%s-%s", OS, arch)
if !strings.HasSuffix(URL, urlSuffix) {
urlWithSuffix = urlWithSuffix + urlSuffix
}
urls := []string{urlWithSuffix, URL}
tmpDir, err := pathutil.NormalizedOSTempDirPath("plugin")
if err != nil {
return err
}
tmpDst := path.Join(tmpDir, fileName)
output, err := os.Create(tmpDst)
if err != nil {
return err
}
defer func() {
if err := output.Close(); err != nil {
log.Errorf("Failed to close file, err: %s", err)
}
}()
success := false
var response *http.Response
for _, aURL := range urls {
response, err = http.Get(aURL)
if response != nil {
defer func() {
if err := response.Body.Close(); err != nil {
log.Errorf("Failed to close response body, err: %s", err)
}
}()
}
if err != nil {
log.Errorf("%s", err)
} else {
success = true
break
}
}
if !success {
return err
}
if _, err := io.Copy(output, response.Body); err != nil {
return err
}
tmpDstFilePath = output.Name()
} else {
tmpDstFilePath = strings.Replace(URL, scheme+"://", "", -1)
}
if err := cmdex.CopyFile(tmpDstFilePath, dst); err != nil {
return err
}
return nil
}
开发者ID:birmacher,项目名称:bitrise,代码行数:80,代码来源:plugins.go
示例11: main
func main() {
configs := createConfigsModelFromEnvs()
configs.print()
if explanation, err := configs.validate(); err != nil {
fmt.Println()
log.Error("Issue with input: %s", err)
fmt.Println()
if explanation != "" {
fmt.Println(explanation)
fmt.Println()
}
os.Exit(1)
}
if configs.ApkFileIncludeFilter == "" {
configs.ApkFileIncludeFilter = "*.apk"
}
err := os.Chmod(configs.GradlewPath, 0770)
if err != nil {
log.Fail("Failed to add executable permission on gradlew file (%s), error: %s", configs.GradlewPath, err)
}
log.Info("Running gradle task...")
if err := runGradleTask(configs.GradlewPath, configs.GradleFile, configs.GradleTasks, configs.GradleOptions); err != nil {
log.Fail("Gradle task failed, error: %s", err)
}
// Move apk files
log.Info("Move apk files...")
apkFiles, err := find(".", configs.ApkFileIncludeFilter, configs.ApkFileExcludeFilter)
if err != nil {
log.Fail("Failed to find apk files, error: %s", err)
}
if len(apkFiles) == 0 {
log.Warn("No apk matched the filters")
}
lastCopiedApkFile := ""
for _, apkFile := range apkFiles {
ext := filepath.Ext(apkFile)
baseName := filepath.Base(apkFile)
baseName = strings.TrimSuffix(baseName, ext)
deployPth, err := findDeployPth(configs.DeployDir, baseName, ext)
if err != nil {
log.Fail("Failed to create apk deploy path, error: %s", err)
}
log.Detail("copy %s to %s", apkFile, deployPth)
cmdex.CopyFile(apkFile, deployPth)
lastCopiedApkFile = deployPth
}
if lastCopiedApkFile != "" {
if err := exportEnvironmentWithEnvman("BITRISE_APK_PATH", lastCopiedApkFile); err != nil {
log.Fail("Failed to export enviroment (BITRISE_APK_PATH), error: %s", err)
}
log.Done("The apk path is now available in the Environment Variable: $BITRISE_APK_PATH (value: %s)", lastCopiedApkFile)
}
// Move mapping files
log.Info("Move mapping files...")
mappingFiles, err := find(".", configs.MappingFileIncludeFilter, configs.MappingFileExcludeFilter)
if err != nil {
log.Fail("Failed to find mapping files, error: %s", err)
}
if len(mappingFiles) == 0 {
log.Detail("No mapping file matched the filters")
}
lastCopiedMappingFile := ""
for _, mappingFile := range mappingFiles {
ext := filepath.Ext(mappingFile)
baseName := filepath.Base(mappingFile)
baseName = strings.TrimSuffix(baseName, ext)
deployPth, err := findDeployPth(configs.DeployDir, baseName, ext)
if err != nil {
log.Fail("Failed to create mapping deploy path, error: %s", err)
}
log.Detail("copy %s to %s", mappingFile, deployPth)
cmdex.CopyFile(mappingFile, deployPth)
lastCopiedMappingFile = deployPth
}
if lastCopiedMappingFile != "" {
if err := exportEnvironmentWithEnvman("BITRISE_MAPPING_PATH", lastCopiedMappingFile); err != nil {
log.Fail("Failed to export enviroment (BITRISE_MAPPING_PATH), error: %s", err)
}
log.Done("The mapping path is now available in the Environment Variable: $BITRISE_MAPPING_PATH (value: %s)", lastCopiedMappingFile)
}
}
开发者ID:bitrise-io,项目名称:steps-gradle-runner,代码行数:100,代码来源:main.go
示例12: InstallPlugin
//.........这里部分代码省略.........
}
//
// Intsall plugin into bitrise
installSuccess := true
pluginDir := GetPluginDir(newPlugin.Name)
if err := os.RemoveAll(pluginDir); err != nil {
return Plugin{}, "", fmt.Errorf("failed to remove plugin dir (%s), error: %s", pluginDir, err)
}
defer func() {
if installSuccess {
return
}
if err := os.RemoveAll(pluginDir); err != nil {
log.Warnf("Failed to remove path (%s)", pluginDir)
}
}()
// Install plugin src
plginSrcDir := GetPluginSrcDir(newPlugin.Name)
if err := os.MkdirAll(plginSrcDir, 0777); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to create plugin src dir (%s), error: %s", plginSrcDir, err)
}
if err := cmdex.CopyDir(pluginSrcTmpDir, plginSrcDir, true); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to copy plugin from temp dir (%s) to (%s), error: %s", pluginSrcTmpDir, plginSrcDir, err)
}
executableURL := newPlugin.ExecutableURL()
if binURL != "" {
executableURL = binURL
}
if executableURL != "" {
// Install plugin bin
pluginBinTmpDir, err := pathutil.NormalizedOSTempDirPath("plugin-bin-tmp")
if err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to create plugin bin temp directory, error: %s", err)
}
defer func() {
if err := os.RemoveAll(pluginBinTmpDir); err != nil {
log.Warnf("Failed to remove path (%s)", pluginBinTmpDir)
}
}()
pluginBinTmpFilePath := filepath.Join(pluginBinTmpDir, newPlugin.Name)
if err := downloadPluginBin(executableURL, pluginBinTmpFilePath); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to download plugin executable from (%s), error: %s", executableURL, err)
}
plginBinDir := GetPluginBinDir(newPlugin.Name)
if err := os.MkdirAll(plginBinDir, 0777); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to create plugin bin dir (%s), error: %s", plginBinDir, err)
}
pluginBinFilePath := filepath.Join(plginBinDir, newPlugin.Name)
if err := cmdex.CopyFile(pluginBinTmpFilePath, pluginBinFilePath); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to copy plugin from temp dir (%s) to (%s), error: %s", pluginBinTmpFilePath, pluginBinFilePath, err)
}
if err := os.Chmod(pluginBinFilePath, 0777); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to make plugin bin executable, error: %s", err)
}
}
newVersionStr := ""
if newVersionPtr != nil {
newVersionStr = (*newVersionPtr).String()
}
pluginDataDir := filepath.Join(pluginDir, "data")
if err := os.MkdirAll(pluginDataDir, 0777); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to create plugin data dir (%s), error: %s", pluginDataDir, err)
}
if err := CreateAndAddPluginRoute(newPlugin.Name, srcURL, executableURL, newVersionStr, newVersinHash, newPlugin.TriggerEvent); err != nil {
installSuccess = false
return Plugin{}, "", fmt.Errorf("failed to add plugin route, error: %s", err)
}
if newVersionStr == "" {
newVersionStr = "local"
}
return newPlugin, newVersionStr, nil
}
开发者ID:godrei,项目名称:bitrise,代码行数:101,代码来源:install.go
示例13: main
//.........这里部分代码省略.........
fail("Export failed, error: %s", err)
}
} else {
logWithTimestamp(colorstring.Green, exportCmd.PrintableCmd())
fmt.Println()
if xcodebuildOut, err := exportCmd.RunAndReturnOutput(); err != nil {
// xcdistributionlogs
if logsDirPth, err := findIDEDistrubutionLogsPath(xcodebuildOut); err != nil {
log.Warn("Failed to find xcdistributionlogs, error: %s", err)
} else if err := utils.ExportOutputDirAsZip(logsDirPth, ideDistributionLogsZipPath, bitriseIDEDistributionLogsPthEnvKey); err != nil {
log.Warn("Failed to export %s, error: %s", bitriseIDEDistributionLogsPthEnvKey, err)
} else {
log.Warn(`If you can't find the reason of the error in the log, please check the xcdistributionlogs
The logs directory is stored in $BITRISE_DEPLOY_DIR, and its full path
is available in the $BITRISE_IDEDISTRIBUTION_LOGS_PATH environment variable`)
}
fail("Export failed, error: %s", err)
}
}
// Search for ipa
pattern := filepath.Join(tmpDir, "*.ipa")
ipas, err := filepath.Glob(pattern)
if err != nil {
fail("Failed to collect ipa files, error: %s", err)
}
if len(ipas) == 0 {
fail("No ipa found with pattern: %s", pattern)
} else if len(ipas) == 1 {
if err := cmdex.CopyFile(ipas[0], ipaPath); err != nil {
fail("Failed to copy (%s) -> (%s), error: %s", ipas[0], ipaPath, err)
}
} else {
log.Warn("More than 1 .ipa file found")
for _, ipa := range ipas {
base := filepath.Base(ipa)
deployPth := filepath.Join(configs.OutputDir, base)
if err := cmdex.CopyFile(ipa, deployPth); err != nil {
fail("Failed to copy (%s) -> (%s), error: %s", ipas[0], ipaPath, err)
}
ipaPath = ipa
}
}
}
log.Info("Exporting outputs...")
//
// Export outputs
// Export .xcarchive
fmt.Println()
if err := utils.ExportOutputDir(tmpArchivePath, tmpArchivePath, bitriseXCArchivePthEnvKey); err != nil {
fail("Failed to export %s, error: %s", bitriseXCArchivePthEnvKey, err)
}
log.Done("The xcarchive path is now available in the Environment Variable: %s (value: %s)", bitriseXCArchivePthEnvKey, tmpArchivePath)
if configs.IsExportXcarchiveZip == "yes" {
开发者ID:bitrise-io,项目名称:steps-xcode-archive,代码行数:67,代码来源:main.go
示例14: activateAndRunSteps
//.........这里部分代码省略.........
}
stepIDData, err := models.CreateStepIDDataFromString(compositeStepIDStr, defaultStepLibSource)
if err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
stepVersionForInfoPrint := stepIDData.Version
log.Debugf("[BITRISE_CLI] - Running Step: %#v", workflowStep)
if err := bitrise.CleanupStepWorkDir(); err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
stepDir := bitrise.BitriseWorkStepsDirPath
stepYMLPth := path.Join(bitrise.BitriseWorkDirPath, "current_step.yml")
if stepIDData.SteplibSource == "path" {
log.Debugf("[BITRISE_CLI] - Local step found: (path:%s)", stepIDData.IDorURI)
stepAbsLocalPth, err := pathutil.AbsPath(stepIDData.IDorURI)
if err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
log.Debugln("stepAbsLocalPth:", stepAbsLocalPth, "|stepDir:", stepDir)
if err := cmdex.CopyDir(stepAbsLocalPth, stepDir, true); err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
if err := cmdex.CopyFile(path.Join(stepAbsLocalPth, "step.yml"), stepYMLPth); err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
if len(stepIDData.IDorURI) > 20 {
stepVersionForInfoPrint = fmt.Sprintf("path:...%s", stringutil.MaxLastChars(stepIDData.IDorURI, 17))
} else {
stepVersionForInfoPrint = fmt.Sprintf("path:%s", stepIDData.IDorURI)
}
} else if stepIDData.SteplibSource == "git" {
log.Debugf("[BITRISE_CLI] - Remote step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)
if err := cmdex.GitCloneTagOrBranch(stepIDData.IDorURI, stepDir, stepIDData.Version); err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
if err := cmdex.CopyFile(path.Join(stepDir, "step.yml"), stepYMLPth); err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
continue
}
stepVersionForInfoPrint = fmt.Sprintf("git:...%s", stringutil.MaxLastChars(stepIDData.IDorURI, 10))
if stepIDData.Version != "" {
stepVersionForInfoPrint = stepVersionForInfoPrint + "@" + stepIDData.Version
}
} else if stepIDData.SteplibSource == "_" {
log.Debugf("[BITRISE_CLI] - Steplib independent step, with direct git uri: (uri:%s) (tag-or-branch:%s)", stepIDData.IDorURI, stepIDData.Version)
// Steplib independent steps are completly defined in workflow
stepYMLPth = ""
if err := workflowStep.FillMissingDefaults(); err != nil {
registerStepListItemRunResults(stepListItm, models.StepRunStatusCodeFailed, 1, err, isLastStep)
开发者ID:benjaminboxler,项目名称:bitrise,代码行数:67,代码来源:run_util.go
注:本文中的github.com/bitrise-io/go-utils/cmdex.CopyFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论