Skip to content

Instantly share code, notes, and snippets.

@dmytrokosiachenko
Created November 2, 2020 09:22
Show Gist options
  • Save dmytrokosiachenko/584542ad5937821f8e97c9f1966c4e48 to your computer and use it in GitHub Desktop.
Save dmytrokosiachenko/584542ad5937821f8e97c9f1966c4e48 to your computer and use it in GitHub Desktop.
Add color to jenkins output
/*
+~~~~~~+~~~~~~+~~~~~~~~~~~+
| fg | bg | color |
+~~~~~~+~~~~~~+~~~~~~~~~~~+
| 30 | 40 | black |
| 31 | 41 | red |
| 32 | 42 | green |
| 33 | 43 | yellow |
| 34 | 44 | blue |
| 35 | 45 | magenta |
| 36 | 46 | cyan |
| 37 | 47 | white |
| 39 | 49 | default |
+~~~~~~+~~~~~~+~~~~~~~~~~~+
*/
private String addColours(int foreground, int background, String text) {
ANSI_RESET = "${(char) 27}[0m"
return "${(char) 27}[$foreground;$background" + "m" + text + ANSI_RESET
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment