Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-59114

Maven output is not colorized

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Hi,

       

      I am trying to use the Maven ansi color plugin to have the Jenkins log colorized the Maven output, but it fails.  Jenkins version is 2.162.

       

      I added to the pipe line the following code-

       

      options

      {         ansiColor('xterm')     }

       

          environment

      {         MAVEN_OPTS = '-Djansi.force=true'     }

       

       

      stage ('Build stage')

                                      {

                                                      steps

      {                                                                                                                 bat 'mvn -version'                                                                 bat 'mvn -Dstyle.color=always clean install'                                                                                                                 }

                                     

                                      }

      The Maven itself is version 3.5.4, but the Jenkins result is without colors

        Attachments

          Activity

          Hide
          famod Falko Modler added a comment -
          Show
          famod Falko Modler added a comment - You have to add -Dstyle.color=always to the mvn invocation ( not to MAVEN_OPTS like jansi.force ). See: https://issues.jenkins-ci.org/browse/JENKINS-44543?focusedCommentId=331794&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-331794
          Hide
          eyalg1972 Eyal Goren added a comment -

          You can see in the description that the mvn command contains this parameter-

           

          bat 'mvn -Dstyle.color=always clean install'

           

          Show
          eyalg1972 Eyal Goren added a comment - You can see in the description that the mvn command contains this parameter-   bat 'mvn -Dstyle.color=always clean install'  
          Hide
          famod Falko Modler added a comment -

          Sorry, must have missed that. The formatting is a bit off, though.

          This actually works for me. The one main difference is that I am using withMaven and then sh "mvn ...". And my Jenkins is running on CentOS 7, yours is a Windows machine...

          Show
          famod Falko Modler added a comment - Sorry, must have missed that. The formatting is a bit off, though. This actually works for me. The one main difference is that I am using withMaven and then sh "mvn ..." . And my Jenkins is running on CentOS 7, yours is a Windows machine...
          Hide
          eyalg1972 Eyal Goren added a comment -

          Can you show me a sample of declarative pipeline- how it should work? I will be happy to test it

          Show
          eyalg1972 Eyal Goren added a comment - Can you show me a sample of declarative pipeline- how it should work? I will be happy to test it
          Hide
          eyalg1972 Eyal Goren added a comment -

          OK, when I use the pipeline maven integration plugin it does work, this issue can be closed

          Show
          eyalg1972 Eyal Goren added a comment - OK, when I use the pipeline maven integration plugin it does work, this issue can be closed

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            eyalg1972 Eyal Goren
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: