本文整理汇总了Golang中github.com/bitrise-io/stepman/models.StepInfoModel.GlobalInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang StepInfoModel.GlobalInfo方法的具体用法?Golang StepInfoModel.GlobalInfo怎么用?Golang StepInfoModel.GlobalInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/bitrise-io/stepman/models.StepInfoModel
的用法示例。
在下文中一共展示了StepInfoModel.GlobalInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: activateAndRunSteps
func activateAndRunSteps(workflow models.WorkflowModel, defaultStepLibSource string, buildRunResults models.BuildRunResultsModel, environments *[]envmanModels.EnvironmentItemModel, isLastWorkflow bool) models.BuildRunResultsModel {
log.Debugln("[BITRISE_CLI] - Activating and running steps")
// ------------------------------------------
// In function global variables - These are global for easy use in local register step run result methods.
var stepStartTime time.Time
// ------------------------------------------
// In function method - Registration methods, for register step run results.
registerStepRunResults := func(step stepmanModels.StepModel, stepInfoPtr stepmanModels.StepInfoModel,
stepIdxPtr int, runIf string, resultCode, exitCode int, err error, isLastStep, printStepHeader bool) {
if printStepHeader {
bitrise.PrintRunningStepHeader(stepInfoPtr, step, stepIdxPtr)
}
stepInfoCopy := stepmanModels.StepInfoModel{
ID: stepInfoPtr.ID,
Title: stepInfoPtr.Title,
Version: stepInfoPtr.Version,
Latest: stepInfoPtr.Latest,
SupportURL: stepInfoPtr.SupportURL,
SourceCodeURL: stepInfoPtr.SourceCodeURL,
GlobalInfo: stepInfoPtr.GlobalInfo,
}
stepResults := models.StepRunResultsModel{
StepInfo: stepInfoCopy,
Status: resultCode,
Idx: buildRunResults.ResultsCount(),
RunTime: time.Now().Sub(stepStartTime),
Error: err,
ExitCode: exitCode,
}
isExitStatusError := true
if err != nil {
isExitStatusError = errorutil.IsExitStatusError(err)
}
switch resultCode {
case models.StepRunStatusCodeSuccess:
buildRunResults.SuccessSteps = append(buildRunResults.SuccessSteps, stepResults)
break
case models.StepRunStatusCodeFailed:
if !isExitStatusError {
log.Errorf("Step (%s) failed, error: %s", stepInfoCopy.Title, err)
}
buildRunResults.FailedSteps = append(buildRunResults.FailedSteps, stepResults)
break
case models.StepRunStatusCodeFailedSkippable:
if !isExitStatusError {
log.Warnf("Step (%s) failed, but was marked as skippable, error: %s", stepInfoCopy.Title, err)
} else {
log.Warnf("Step (%s) failed, but was marked as skippable", stepInfoCopy.Title)
}
buildRunResults.FailedSkippableSteps = append(buildRunResults.FailedSkippableSteps, stepResults)
break
case models.StepRunStatusCodeSkipped:
log.Warnf("A previous step failed, and this step (%s) was not marked as IsAlwaysRun, skipped", stepInfoCopy.Title)
buildRunResults.SkippedSteps = append(buildRunResults.SkippedSteps, stepResults)
break
case models.StepRunStatusCodeSkippedWithRunIf:
log.Warn("The step's (" + stepInfoCopy.Title + ") Run-If expression evaluated to false - skipping")
if runIf != "" {
log.Info("The Run-If expression was: ", colorstring.Blue(runIf))
}
buildRunResults.SkippedSteps = append(buildRunResults.SkippedSteps, stepResults)
break
default:
log.Error("Unkown result code")
return
}
bitrise.PrintRunningStepFooter(stepResults, isLastStep)
}
// ------------------------------------------
// Main - Preparing & running the steps
for idx, stepListItm := range workflow.Steps {
// Per step variables
stepStartTime = time.Now()
isLastStep := isLastWorkflow && (idx == len(workflow.Steps)-1)
stepInfoPtr := stepmanModels.StepInfoModel{}
stepIdxPtr := idx
// Per step cleanup
if err := bitrise.SetBuildFailedEnv(buildRunResults.IsBuildFailed()); err != nil {
log.Error("Failed to set Build Status envs")
}
if err := bitrise.CleanupStepWorkDir(); err != nil {
registerStepRunResults(stepmanModels.StepModel{}, stepInfoPtr, stepIdxPtr,
"", models.StepRunStatusCodeFailed, 1, err, isLastStep, true)
continue
}
//.........这里部分代码省略.........
示例2: stepInfo
//.........这里部分代码省略.........
if err != nil {
return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", YMLPath, err)
}
stepInfo := models.StepInfoModel{
StepLib: YMLPath,
Description: *step.Description,
Source: *step.SourceCodeURL,
Inputs: inputs,
Outputs: outputs,
}
if err := printStepInfo(stepInfo, format, isShort, true); err != nil {
return fmt.Errorf("Failed to print step info, err: %s", err)
}
} else {
//
// StepLib step info
// Input validation
if id == "" {
return errors.New("Missing required input: step id")
}
// Check if setup was done for collection
if exist, err := stepman.RootExistForCollection(collectionURI); err != nil {
return fmt.Errorf("Failed to check if setup was done for steplib (%s), error: %s", collectionURI, err)
} else if !exist {
if err := setupSteplib(collectionURI, format != OutputFormatRaw); err != nil {
return errors.New("Failed to setup steplib")
}
}
// Check if step exist in collection
collection, err := stepman.ReadStepSpec(collectionURI)
if err != nil {
return fmt.Errorf("Failed to read steps spec (spec.json), err: %s", err)
}
step, stepFound := collection.GetStep(id, version)
if !stepFound {
if version == "" {
return fmt.Errorf("Collection doesn't contain any version of step (id:%s)", id)
}
return fmt.Errorf("Collection doesn't contain step (id:%s) (version:%s)", id, version)
}
latest, err := collection.GetLatestStepVersion(id)
if err != nil {
return fmt.Errorf("Failed to get latest version of step (id:%s)", id)
}
if version == "" {
version = latest
}
inputs, err := getEnvInfos(step.Inputs)
if err != nil {
return fmt.Errorf("Failed to get step (id:%s) input infos, err: %s", id, err)
}
outputs, err := getEnvInfos(step.Outputs)
if err != nil {
return fmt.Errorf("Failed to get step (id:%s) output infos, err: %s", id, err)
}
stepInfo := models.StepInfoModel{
ID: id,
Version: version,
Latest: latest,
Description: *step.Description,
StepLib: collectionURI,
Source: *step.SourceCodeURL,
Inputs: inputs,
Outputs: outputs,
}
route, found := stepman.ReadRoute(collectionURI)
if !found {
return fmt.Errorf("No route found for collection: %s", collectionURI)
}
globalStepInfoPth := stepman.GetStepGlobalInfoPath(route, id)
if globalStepInfoPth != "" {
globalInfo, found, err := stepman.ParseGlobalStepInfoYML(globalStepInfoPth)
if err != nil {
return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", globalStepInfoPth, err)
}
if found {
stepInfo.GlobalInfo = globalInfo
}
}
if err := printStepInfo(stepInfo, format, isShort, false); err != nil {
return fmt.Errorf("Failed to print step info, err: %s", err)
}
}
return nil
}
示例3: stepInfo
func stepInfo(c *cli.Context) error {
// Input validation
format := c.String(FormatKey)
collectionURI := c.String(CollectionKey)
YMLPath := c.String(StepYMLKey)
isShort := c.Bool(ShortKey)
id := c.String(IDKey)
version := c.String(VersionKey)
if format == "" {
format = OutputFormatRaw
} else if !(format == OutputFormatRaw || format == OutputFormatJSON) {
return fmt.Errorf("Invalid output format: %s", format)
}
if YMLPath == "" && collectionURI == "" {
return fmt.Errorf("Missing required input: no StepLib, nor step.yml path defined as step info source")
}
if YMLPath != "" {
//
// Local step info
step, err := stepman.ParseStepYml(YMLPath, false)
if err != nil {
return fmt.Errorf("Failed to parse step.yml (path:%s), err: %s", YMLPath, err)
}
inputs, err := getEnvInfos(step.Inputs)
if err != nil {
return fmt.Errorf("Failed to get step (path:%s) input infos, err: %s", YMLPath, err)
}
outputs, err := getEnvInfos(step.Outputs)
if err != nil {
return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", YMLPath, err)
}
stepInfo := models.StepInfoModel{
StepLib: YMLPath,
Description: *step.Description,
Source: *step.SourceCodeURL,
Inputs: inputs,
Outputs: outputs,
}
if err := printStepInfo(stepInfo, format, isShort, true); err != nil {
return fmt.Errorf("Failed to print step info, err: %s", err)
}
} else {
//
// StepLib step info
stepVersion, err := ReadStepInfo(collectionURI, id, version, true, format != OutputFormatRaw)
if err != nil {
return fmt.Errorf("Failed to read Step information, error: %s", err)
}
if version == "" {
version = stepVersion.Version
}
step := stepVersion.Step
inputs, err := getEnvInfos(step.Inputs)
if err != nil {
return fmt.Errorf("Failed to get step (id:%s) input infos, err: %s", id, err)
}
outputs, err := getEnvInfos(step.Outputs)
if err != nil {
return fmt.Errorf("Failed to get step (id:%s) output infos, err: %s", id, err)
}
stepInfo := models.StepInfoModel{
ID: id,
Version: version,
Latest: stepVersion.LatestAvailableVersion,
Description: *step.Description,
StepLib: collectionURI,
Source: *step.SourceCodeURL,
Inputs: inputs,
Outputs: outputs,
}
route, found := stepman.ReadRoute(collectionURI)
if !found {
return fmt.Errorf("No route found for collection: %s", collectionURI)
}
globalStepInfoPth := stepman.GetStepGlobalInfoPath(route, id)
if globalStepInfoPth != "" {
globalInfo, found, err := stepman.ParseGlobalStepInfoYML(globalStepInfoPth)
if err != nil {
return fmt.Errorf("Failed to get step (path:%s) output infos, err: %s", globalStepInfoPth, err)
}
if found {
stepInfo.GlobalInfo = globalInfo
}
}
if err := printStepInfo(stepInfo, format, isShort, false); err != nil {
//.........这里部分代码省略.........