Skip to content

Commit

Permalink
Show analyzerManager logs in CI (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas authored Feb 5, 2024
1 parent 0fc5abe commit a9084e2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions utils/analyzermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (am *AnalyzerManager) ExecWithOutputFile(configFile, scanCommand, workingDi
}()
cmd.Dir = workingDir
output, err := cmd.CombinedOutput()
if err != nil {
if isCI() || err != nil {
if len(output) > 0 {
log.Debug(fmt.Sprintf("%s %q output: %s", workingDir, strings.Join(cmd.Args, " "), string(output)))
}
Expand Down Expand Up @@ -165,6 +165,10 @@ func GetAnalyzerManagerExecutableName() string {
return analyzerManager
}

func isCI() bool {
return strings.ToLower(os.Getenv(coreutils.CI)) == "true"
}

func SetAnalyzerManagerEnvVariables(serverDetails *config.ServerDetails) error {
if serverDetails == nil {
return errors.New("cant get xray server details")
Expand All @@ -181,12 +185,14 @@ func SetAnalyzerManagerEnvVariables(serverDetails *config.ServerDetails) error {
if err := os.Setenv(jfTokenEnvVariable, serverDetails.AccessToken); errorutils.CheckError(err) != nil {
return err
}
analyzerManagerLogFolder, err := coreutils.CreateDirInJfrogHome(filepath.Join(coreutils.JfrogLogsDirName, analyzerManagerLogDirName))
if err != nil {
return err
}
if err = os.Setenv(logDirEnvVariable, analyzerManagerLogFolder); errorutils.CheckError(err) != nil {
return err
if !isCI() {
analyzerManagerLogFolder, err := coreutils.CreateDirInJfrogHome(filepath.Join(coreutils.JfrogLogsDirName, analyzerManagerLogDirName))
if err != nil {
return err
}
if err = os.Setenv(logDirEnvVariable, analyzerManagerLogFolder); errorutils.CheckError(err) != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit a9084e2

Please sign in to comment.