func BuildCollectEnv(buildName, buildNumber string) (err error) { if err = utils.SaveBuildGeneralDetails(buildName, buildNumber); err != nil { return } populateFunc := func(tempWrapper *utils.ArtifactBuildInfoWrapper) { tempWrapper.Env = getEnvVariables() } err = utils.PrepareBuildInfoForSave(buildName, buildNumber, populateFunc) return }
func Download(downloadSpec *utils.SpecFiles, flags *DownloadFlags) (err error) { err = utils.PreCommandSetup(flags) if err != nil { return } isCollectBuildInfo := len(flags.BuildName) > 0 && len(flags.BuildNumber) > 0 if isCollectBuildInfo && !flags.DryRun { if err = utils.SaveBuildGeneralDetails(flags.BuildName, flags.BuildNumber); err != nil { return } } if !flags.DryRun { err = ioutils.CreateTempDirPath() if err != nil { return } defer ioutils.RemoveTempDir() } buildDependecies := make([][]utils.DependenciesBuildInfo, flags.Threads) log.Info("Searching artifacts...") var downloadData []DownloadData for i := 0; i < len(downloadSpec.Files); i++ { var partialDownloadData []DownloadData switch downloadSpec.Get(i).GetSpecType() { case utils.WILDCARD, utils.SIMPLE: partialDownloadData, err = collectWildcardDependecies(downloadSpec.Get(i), flags) case utils.AQL: partialDownloadData, err = collectAqlDependecies(downloadSpec.Get(i), flags) } if err != nil { return } downloadData = append(downloadData, partialDownloadData...) } utils.LogSearchResults(len(downloadData)) buildDependecies, err = downloadAqlResult(downloadData, flags) if err != nil { return } if isCollectBuildInfo && !flags.DryRun { populateFunc := func(tempWrapper *utils.ArtifactBuildInfoWrapper) { tempWrapper.Dependencies = stripThreadIdFromBuildInfoDependencies(buildDependecies) } err = utils.PrepareBuildInfoForSave(flags.BuildName, flags.BuildNumber, populateFunc) } return }
// Uploads the artifacts in the specified local path pattern to the specified target path. // Returns the total number of artifacts successfully uploaded. func Upload(uploadSpec *utils.SpecFiles, flags *UploadFlags) (totalUploaded, totalFailed int, err error) { err = utils.PreCommandSetup(flags) if err != nil { return 0, 0, err } isCollectBuildInfo := len(flags.BuildName) > 0 && len(flags.BuildNumber) > 0 if isCollectBuildInfo && !flags.DryRun { if err := utils.SaveBuildGeneralDetails(flags.BuildName, flags.BuildNumber); err != nil { return 0, 0, err } } spinner := cliutils.NewSpinner("[Info] Collecting files for upload:", time.Second) spinner.Start() uploadData, err := buildUploadData(uploadSpec, flags) spinner.Stop() if err != nil { return 0, 0, err } buildArtifacts, totalUploaded, totalFailed, err := uploadWildcard(uploadData, flags) if err != nil { return 0, 0, err } if totalFailed > 0 { return } if isCollectBuildInfo && !flags.DryRun { populateFunc := func(tempWrapper *utils.ArtifactBuildInfoWrapper) { tempWrapper.Artifacts = toBuildInfoArtifacts(buildArtifacts) } err = utils.PrepareBuildInfoForSave(flags.BuildName, flags.BuildNumber, populateFunc) } return }