Esempio n. 1
0
func performRunOrTriggerWithCmdBridge(bitriseCommandToUse, inventoryBase64, configBase64, runParamJSONBase64, workflowNameOrTriggerPattern, workdirPath string) error {
	bitriseCallArgs := createBitriseCallArgs(bitriseCommandToUse, inventoryBase64, configBase64, runParamJSONBase64, workflowNameOrTriggerPattern)
	log.Debugf("=> (debug) bitriseCallArgs: %s", bitriseCallArgs)

	bitriseCmdStr := fmt.Sprintf("bitrise %s", strings.Join(bitriseCallArgs, " "))
	args := []string{"-workdir", workdirPath, "-do", bitriseCmdStr}

	if err := cmdex.RunCommand("cmd-bridge", args...); err != nil {
		log.Debugf("cmd: `%s` failed, error: %s", bitriseCmdStr)
		return err
	}

	return nil
}
Esempio n. 2
0
func performRunOrTriggerWithDocker(bridgeConfig config.Model, bitriseCommandToUse, inventoryBase64, configBase64, runParamJSONBase64, workflowNameOrTriggerPattern, workdirPath string) error {
	dockerParamImageToUse := bridgeConfig.Docker.Image
	if dockerParamImageToUse == "" {
		return errors.New("No docker-image-id specified")
	}
	dockerParamIsAllowAccessToDockerInContainer := bridgeConfig.Docker.IsAllowAccessToDockerInContainer

	bitriseCallArgs := createBitriseCallArgs(bitriseCommandToUse, inventoryBase64, configBase64, runParamJSONBase64, workflowNameOrTriggerPattern)
	log.Debugf("=> (debug) bitriseCallArgs: %s", bitriseCallArgs)

	fullDockerArgs := []string{
		"run", "--rm",
	}
	if dockerParamIsAllowAccessToDockerInContainer {
		// mount the docker.sock socker & the docker binary as volumes, to make it
		//  accessible inside the container
		dockerPth, err := cmdex.RunCommandAndReturnStdout("which", "docker")
		if err != nil || dockerPth == "" {
			return errors.New("Failed to determin docker binary path; required for the 'docker-allow-access-to-docker-in-container' option")
		}
		fullDockerArgs = append(fullDockerArgs,
			"-v", "/var/run/docker.sock:/var/run/docker.sock",
			"-v", fmt.Sprintf("%s:%s", dockerPth, "/bin/docker"),
		)
	}
	if len(bridgeConfig.Docker.Volumes) > 0 {
		for _, aVolDef := range bridgeConfig.Docker.Volumes {
			fullDockerArgs = append(fullDockerArgs, "-v", aVolDef)
		}
	}
	if len(bridgeConfig.Docker.AdditionalRunArguments) > 0 {
		fullDockerArgs = append(fullDockerArgs, bridgeConfig.Docker.AdditionalRunArguments...)
	}
	// these are the docker specific params
	fullDockerArgs = append(fullDockerArgs, dockerParamImageToUse)
	// append Bitrise specific params
	fullDockerArgs = append(fullDockerArgs, "bitrise")
	fullDockerArgs = append(fullDockerArgs, bitriseCallArgs...)

	log.Debugf("fullDockerArgs: %#v", fullDockerArgs)

	if err := cmdex.RunCommand("docker", fullDockerArgs...); err != nil {
		log.Debugf("cmd: `docker %s` failed, error: %s", fullDockerArgs)
		return err
	}

	return nil
}
Esempio n. 3
0
func exportProvisioningProfiles(provProfileFileInfos []provprofile.ProvisioningProfileFileInfoModel,
	exportTargetDirPath string) error {

	for idx, aProvProfileFileInfo := range provProfileFileInfos {
		if idx != 0 {
			fmt.Println()
		}
		provProfileInfo := aProvProfileFileInfo.ProvisioningProfileInfo
		log.Infoln("   "+colorstring.Green("Exporting Provisioning Profile:"), provProfileInfo.Name)
		log.Infoln("                      App ID Name:", provProfileInfo.AppIDName)
		log.Infoln("                           App ID:", provProfileInfo.Entitlements.AppID)
		log.Infoln("                  Expiration Date:", provProfileInfo.ExpirationDate)
		log.Infoln("                             UUID:", provProfileInfo.UUID)
		log.Infoln("                         TeamName:", provProfileInfo.TeamName)
		log.Infoln("                          Team ID:", provProfileInfo.Entitlements.TeamID)
		exportFileName := provProfileExportFileName(aProvProfileFileInfo)
		exportPth := filepath.Join(exportTargetDirPath, exportFileName)
		if err := cmdex.RunCommand("cp", aProvProfileFileInfo.Path, exportPth); err != nil {
			return fmt.Errorf("Failed to copy Provisioning Profile (from: %s) (to: %s), error: %s",
				aProvProfileFileInfo.Path, exportPth, err)
		}
	}
	return nil
}
Esempio n. 4
0
// EnvmanInitAtPath ...
func EnvmanInitAtPath(pth string) error {
	logLevel := log.GetLevel().String()
	args := []string{"--loglevel", logLevel, "--path", pth, "init", "--clear"}
	return cmdex.RunCommand("envman", args...)
}
Esempio n. 5
0
// EnvmanInit ...
func EnvmanInit() error {
	logLevel := log.GetLevel().String()
	args := []string{"--loglevel", logLevel, "init"}
	return cmdex.RunCommand("envman", args...)
}
Esempio n. 6
0
// StepmanUpdate ...
func StepmanUpdate(collection string) error {
	logLevel := log.GetLevel().String()
	args := []string{"--debug", "--loglevel", logLevel, "update", "--collection", collection}
	return cmdex.RunCommand("stepman", args...)
}
Esempio n. 7
0
// StepmanActivate ...
func StepmanActivate(collection, stepID, stepVersion, dir, ymlPth string) error {
	logLevel := log.GetLevel().String()
	args := []string{"--debug", "--loglevel", logLevel, "activate", "--collection", collection,
		"--id", stepID, "--version", stepVersion, "--path", dir, "--copyyml", ymlPth}
	return cmdex.RunCommand("stepman", args...)
}
Esempio n. 8
0
// StepmanShareStart ...
func StepmanShareStart(collection string) error {
	logLevel := log.GetLevel().String()
	args := []string{"--loglevel", logLevel, "share", "start", "--collection", collection, "--toolmode"}
	return cmdex.RunCommand("stepman", args...)
}
Esempio n. 9
0
// StepmanShareFinish ...
func StepmanShareFinish() error {
	logLevel := log.GetLevel().String()
	args := []string{"--loglevel", logLevel, "share", "finish", "--toolmode"}
	return cmdex.RunCommand("stepman", args...)
}
Esempio n. 10
0
// StepmanShareCreate ...
func StepmanShareCreate(tag, git, stepID string) error {
	logLevel := log.GetLevel().String()
	args := []string{"--loglevel", logLevel, "share", "create", "--tag", tag, "--git", git, "stepid", stepID, "--toolmode"}
	return cmdex.RunCommand("stepman", args...)
}
Esempio n. 11
0
func exportCodeSigningFiles(toolName, absExportOutputDirPath string, codeSigningSettings common.CodeSigningSettings) error {
	fmt.Println()
	fmt.Println()
	utils.Printlnf("=== Required Identities/Certificates (%d) ===", len(codeSigningSettings.Identities))
	for idx, anIdentity := range codeSigningSettings.Identities {
		utils.Printlnf(" * (%d): %s", idx+1, anIdentity.Title)
	}
	fmt.Println("============================================")

	fmt.Println()
	utils.Printlnf("=== Required Provisioning Profiles (%d) ===", len(codeSigningSettings.ProvProfiles))
	for idx, aProvProfile := range codeSigningSettings.ProvProfiles {
		utils.Printlnf(" * (%d): %s (UUID: %s)", idx+1, aProvProfile.Title, aProvProfile.UUID)
	}
	fmt.Println("==========================================")

	fmt.Println()
	utils.Printlnf("=== Team IDs (%d) ===", len(codeSigningSettings.TeamIDs))
	for idx, aTeamID := range codeSigningSettings.TeamIDs {
		utils.Printlnf(" * (%d): %s", idx+1, aTeamID)
	}
	fmt.Println("==========================================")

	fmt.Println()
	utils.Printlnf("=== App/Bundle IDs (%d) ===", len(codeSigningSettings.AppIDs))
	for idx, anAppBundleID := range codeSigningSettings.AppIDs {
		utils.Printlnf(" * (%d): %s", idx+1, anAppBundleID)
	}
	fmt.Println("==========================================")
	fmt.Println()

	//
	// --- Code Signing issue checks / report
	//

	if len(codeSigningSettings.Identities) < 1 {
		return printFinishedWithError(toolName, "No Code Signing Identity detected!")
	}
	if len(codeSigningSettings.Identities) > 1 {
		log.Warning(colorstring.Yellow("More than one Code Signing Identity (certificate) is required to sign your app!"))
		log.Warning("You should check your settings and make sure a single Identity/Certificate can be used")
		log.Warning(" for Archiving your app!")
	}

	if len(codeSigningSettings.ProvProfiles) < 1 {
		return printFinishedWithError(toolName, "No Provisioning Profiles detected!")
	}

	//
	// --- Export
	//

	if !isAllowExport {
		isShouldExport, err := goinp.AskForBoolWithDefault("Do you want to export these files?", true)
		if err != nil {
			return printFinishedWithError(toolName, "Failed to process your input: %s", err)
		}
		if !isShouldExport {
			printFinished()
			return nil
		}
	} else {
		log.Debug("Allow Export flag was set - doing export without asking")
	}

	exportedProvProfiles, err := collectAndExportProvisioningProfiles(codeSigningSettings, absExportOutputDirPath)
	if err != nil {
		return printFinishedWithError(toolName, "Failed to export Provisioning Profiles, error: %s", err)
	}

	if err := collectAndExportIdentities(codeSigningSettings, exportedProvProfiles.CollectTeamIDs(), absExportOutputDirPath); err != nil {
		return printFinishedWithError(toolName, "Failed to export identities, error: %s", err)
	}

	fmt.Println()
	fmt.Printf(colorstring.Green("Exports finished")+" you can find the exported files at: %s\n", absExportOutputDirPath)
	if err := cmdex.RunCommand("open", absExportOutputDirPath); err != nil {
		log.Errorf("Failed to open the export directory in Finder: %s", absExportOutputDirPath)
	}
	fmt.Println("Opened the directory in Finder.")
	fmt.Println()

	printFinished()
	return nil
}