Exemple #1
0
func trigger(c *cli.Context) {
	PrintBitriseHeaderASCIIArt(c.App.Version)

	if !bitrise.CheckIsSetupWasDoneForVersion(c.App.Version) {
		log.Warnln(colorstring.Yellow("Setup was not performed for this version of bitrise, doing it now..."))
		if err := bitrise.RunSetup(c.App.Version, false); err != nil {
			log.Fatalln("Setup failed:", err)
		}
	}

	startTime := time.Now()

	// ------------------------
	// Input validation

	// Inventory validation
	inventoryEnvironments, err := CreateInventoryFromCLIParams(c)
	if err != nil {
		log.Fatalf("Failed to create inventory, err: %s", err)
	}
	if err := checkCIAndPRModeFromSecrets(inventoryEnvironments); err != nil {
		log.Fatalf("Failed to check  PR and CI mode, err: %s", err)
	}

	// Config validation
	bitriseConfig, err := CreateBitriseConfigFromCLIParams(c)
	if err != nil {
		log.Fatalf("Failed to create bitrise cofing, err: %s", err)
	}

	// Trigger filter validation
	triggerPattern := ""
	if len(c.Args()) < 1 {
		log.Errorln("No workfow specified!")
	} else {
		triggerPattern = c.Args()[0]
	}

	if triggerPattern == "" {
		// no trigger filter specified
		//  list all the available ones and then exit
		printAvailableTriggerFilters(bitriseConfig.TriggerMap)
	}

	workflowToRunID, err := GetWorkflowIDByPattern(bitriseConfig, triggerPattern)
	if err != nil {
		log.Fatalf("Faild to select workflow by pattern (%s), err: %s", triggerPattern, err)
	}
	log.Infof("Pattern (%s) triggered workflow (%s) ", triggerPattern, workflowToRunID)

	// Run selected configuration
	if _, err := runWorkflowWithConfiguration(startTime, workflowToRunID, bitriseConfig, inventoryEnvironments); err != nil {
		log.Fatalln("Error: ", err)
	}
}
Exemple #2
0
func run(c *cli.Context) {
	PrintBitriseHeaderASCIIArt(c.App.Version)
	log.Debugln("[BITRISE_CLI] - Run")

	if !bitrise.CheckIsSetupWasDoneForVersion(c.App.Version) {
		log.Warnln(colorstring.Yellow("Setup was not performed for this version of bitrise, doing it now..."))
		if err := bitrise.RunSetup(c.App.Version, false); err != nil {
			log.Fatalln("Setup failed:", err)
		}
	}

	startTime := time.Now()

	// Inventory validation
	inventoryEnvironments, err := CreateInventoryFromCLIParams(c)
	if err != nil {
		log.Fatalf("Failed to create inventory, err: %s", err)
	}
	if err := checkCIAndPRModeFromSecrets(inventoryEnvironments); err != nil {
		log.Fatalf("Failed to check  PR and CI mode, err: %s", err)
	}

	// Config validation
	bitriseConfig, err := CreateBitriseConfigFromCLIParams(c)
	if err != nil {
		log.Fatalf("Failed to create bitrise config, err: %s", err)
	}

	// Workflow validation
	workflowToRunID := ""
	if len(c.Args()) < 1 {
		log.Errorln("No workfow specified!")
	} else {
		workflowToRunID = c.Args()[0]
	}

	if workflowToRunID == "" {
		// no workflow specified
		//  list all the available ones and then exit
		printAvailableWorkflows(bitriseConfig)
	}
	if strings.HasPrefix(workflowToRunID, "_") {
		// util workflow specified
		//  print about util workflows and then exit
		printAboutUtilityWorkflos()
	}

	// Run selected configuration
	if _, err := runWorkflowWithConfiguration(startTime, workflowToRunID, bitriseConfig, inventoryEnvironments); err != nil {
		log.Fatalln("Error: ", err)
	}
}
Exemple #3
0
func setup(c *cli.Context) {
	PrintBitriseHeaderASCIIArt(c.App.Version)

	if err := bitrise.RunSetup(c.App.Version, c.Bool(MinimalModeKey)); err != nil {
		log.Fatalln("Setup failed:", err)
	}

	log.Infoln("To start using bitrise:")
	log.Infoln("* cd into your project's directory (if you're not there already)")
	log.Infoln("* call: bitrise init")
	log.Infoln("* follow the guide")
	fmt.Println()
	log.Infoln("That's all :)")
}
Exemple #4
0
func runAndExit(bitriseConfig models.BitriseDataModel, inventoryEnvironments []envmanModels.EnvironmentItemModel, workflowToRunID string) {
	if workflowToRunID == "" {
		log.Fatal("No workflow id specified")
	}

	if !configs.CheckIsSetupWasDoneForVersion(version.VERSION) {
		log.Warnln(colorstring.Yellow("Setup was not performed for this version of bitrise, doing it now..."))
		if err := bitrise.RunSetup(version.VERSION, false); err != nil {
			log.Fatalf("Setup failed, error: %s", err)
		}
	}

	startTime := time.Now()

	// Run selected configuration
	if buildRunResults, err := runWorkflowWithConfiguration(startTime, workflowToRunID, bitriseConfig, inventoryEnvironments); err != nil {
		log.Fatalf("Failed to run workflow, error: %s", err)
	} else if buildRunResults.IsBuildFailed() {
		os.Exit(1)
	}
	os.Exit(0)
}
Exemple #5
0
func setup(c *cli.Context) error {
	PrintBitriseHeaderASCIIArt(c.App.Version)

	if c.IsSet(MinimalModeKey) {
		log.Warn("'minimal' flag is deprecated")
		log.Warn("currently setup without any flag does the same as minimal setup in previous versions")
		log.Warn("use 'full' flag to achive the full setup process (which includes the 'brew doctor' call)")
		fmt.Println()
	}

	if err := bitrise.RunSetup(c.App.Version, c.Bool(FullModeKey)); err != nil {
		log.Fatalf("Setup failed, error: %s", err)
	}

	log.Infoln("To start using bitrise:")
	log.Infoln("* cd into your project's directory (if you're not there already)")
	log.Infoln("* call: bitrise init")
	log.Infoln("* follow the guide")
	fmt.Println()
	log.Infoln("That's all :)")

	return nil
}