Skip to content

Commit d881b82

Browse files
color fix - output var fix
1 parent 4ada002 commit d881b82

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

plugin.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func displaySummary(total, passed, failed int, errors int, newErrors int, projec
200200

201201
// Get the path for DRONE_OUTPUT
202202
droneOutputPath := os.Getenv("DRONE_OUTPUT")
203+
fmt.Print("\nDRONE_OUTPUT var: " + droneOutputPath + "\n")
203204
if droneOutputPath == "" {
204205
fmt.Print("\nError: DRONE_OUTPUT environment variable not set.\n")
205206
fmt.Print("\nError: Probably you are not running in Harness or Drone.\n")
@@ -222,23 +223,11 @@ func displaySummary(total, passed, failed int, errors int, newErrors int, projec
222223
if successRate >= 90 {
223224
category = "\033[32mExcellent\033[0m" // Green
224225
} else if successRate >= 70 {
225-
category = "\033[1;34mGood\033[0m" // Blue
226+
category = "\033[1;34mGood\033[0m" // Light Blue
226227
} else {
227-
category = "\033[1;31mNeeds Improvement\033[0m" // Red
228+
category = "\033[1;31mNeeds Improvement\033[0m" // Light Red
228229
}
229230

230-
// Display the table
231-
fmt.Println("----------------------------------------------")
232-
fmt.Printf("| STATUS | COUNT |\n")
233-
fmt.Println("----------------------------------------------")
234-
fmt.Printf("| (\033[32mPASSED\033[0m) | %d |\n", passed)
235-
fmt.Println("----------------------------------------------")
236-
fmt.Printf("| (\033[31mFAILED\033[0m) | %d |\n", failed)
237-
fmt.Println("----------------------------------------------")
238-
fmt.Printf("| TOTAL | %d |\n", total)
239-
fmt.Println("----------------------------------------------")
240-
fmt.Printf("\n\nCategorization: %s\n", category)
241-
242231
// Prepare your environment variables
243232
vars := map[string]string{
244233
"SONAR_RESULT_SUCCESS_RATE": fmt.Sprintf("%.2f", successRate),
@@ -255,18 +244,32 @@ func displaySummary(total, passed, failed int, errors int, newErrors int, projec
255244
file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
256245
if err != nil {
257246
fmt.Println("Error opening/creating .env file:", err)
258-
return
247+
// return
259248
}
260-
defer file.Close()
261249

262250
for key, value := range vars {
251+
fmt.Println("Writing to .env file:", key, value)
263252
_, err = file.WriteString(fmt.Sprintf("%s=%s\n", key, value))
264253
if err != nil {
265254
fmt.Println("Error writing to .env file:", err)
266-
return
255+
// return
267256
}
268257
}
269-
258+
fmt.Println("Successfully wrote to .env file")
259+
defer file.Close()
260+
fmt.Println("Successfully closed .env file")
261+
fmt.Print("\n\n")
262+
// Display the table
263+
fmt.Println("----------------------------------------------")
264+
fmt.Printf("| STATUS | COUNT |\n")
265+
fmt.Println("----------------------------------------------")
266+
fmt.Printf("| (\033[32mPASSED\033[0m) | %d |\n", passed)
267+
fmt.Println("----------------------------------------------")
268+
fmt.Printf("| (\033[31mFAILED\033[0m) | %d |\n", failed)
269+
fmt.Println("----------------------------------------------")
270+
fmt.Printf("| TOTAL | %d |\n", total)
271+
fmt.Println("----------------------------------------------")
272+
fmt.Printf("\n\nCategorization: %s\n", category)
270273
}
271274

272275
func ParseJunit(projectArray Project, projectName string) Testsuites {

0 commit comments

Comments
 (0)