I'm unsure of what to do with declarative jenkins pipeline.
Following the example here: https://github.com/jenkinsci/ansicolor-plugin
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) { sh 'something that outputs ansi colored stuff' }
Where does the above snippet go?
Here is my simple Jenkinsfile:
#!groovy pipeline { agent any // Set log rotation, timeout and timestamps in the console options { buildDiscarder(logRotator(numToKeepStr:'10')) timeout(time: 5, unit: 'MINUTES') } stages { stage('Initialize') { steps { sh ''' java -version node --version npm --version ''' } } } }
Does the wrapper go around stages? Does it go around each stage?
Jenkins ANSI Color PluginThis plugin adds support for standard ANSI escape sequences, including color, to Console Output. This plugin is available here and has a page on the Jenkins Wiki.
Jenkins 1.580. 1 or later (Jenkins 2.0 is recommended) The core Pipeline plugin.
This plugin is available here and has a page on the Jenkins Wiki. There are 2 ways to explicitly enable ansicolor functionality in a pipeline: as a build wrapper - the cleanest and most preferable one or as a pipeline step - good for quick checks when you only need part of the output colored.
Jenkins ANSI Color Plugin. This plugin adds support for standard ANSI escape sequences, including color, to Console Output. This plugin is available here and has a page on the Jenkins Wiki.
Few examples of plugins which have Jenkins Pipeline support examples on wiki pages: Slack Plugin SonarQube Scanner Stash Build Notifier Easy way #2 We can use snippet generatorfrom Jenkins. Hard way
The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page. For a list of other such plugins, see the Pipeline Steps Reference page.
Able to consolidate config in the options block like so
options { buildDiscarder(logRotator(numToKeepStr:'10')) timeout(time: 5, unit: 'MINUTES') ansiColor('xterm') }
I put mine in each stage like this:
stage('Initialize') { ansiColor('xterm') { // do stuff } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With