首页 > 解决方案 > i am getting [0m[[0m[0minfo[0m] [0m[0m in jenkins console on building sbt jenkins pipeline project

问题描述

i have an sbt project in jenkins, created the project as jenkins pipeline project, i have installed sbt in jenkins, i have checked the auto install checkbox and select the version number 1.2.8

here is my jenkins file

pipeline {
    agent any

    stages {
        stage('Reload') {
            steps {
                echo "Reloading..."
                //sh "sbt reload"
                 sh "${tool name: 'sbt1.2.8', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'}/bin/sbt compile"
            }
        }
}
}

and here is sbt settings in jenkins 

enter image description here

here is jenkins console logs

+ /var/lib/jenkins/tools/org.jvnet.hudson.plugins.SbtPluginBuilder_SbtInstallation/sbt1.2.8/bin/sbt compile
[0m[[0m[0minfo[0m] [0m[0mLoading settings for project interpret-backend-project-jenkinsfile-build from plugins.sbt ...[0m
[0m[[0m[0minfo[0m] [0m[0mLoading project definition from /var/lib/jenkins/workspace/interpret-backend-project-jenkinsfile/project[0m
[0m[[0m[0minfo[0m] [0m[0mLoading settings for project interpret-backend-project-jenkinsfile from build.sbt ...[0m
[0m[[0m[0minfo[0m] [0m[0mSet current project to interpret (in build file:/var/lib/jenkins/workspace/interpret-backend-project-jenkinsfile/)[0m
[0m[[0m[0minfo[0m] [0m[0mExecuting in batch mode. For better performance use sbt's shell[0m
[0m[[0m[32msuccess[0m] [0m[0mTotal time: 4 s, completed Nov 25, 2020, 4:53:05 PM[0m
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[Checks API] No suitable checks publisher found.
Finished: SUCCESS
[0m[[0m[0minfo[0m] [0m[0m why is this displaying how can i fix this ? 

标签: jenkinssbt

解决方案


这些是 ANSI 颜色代码。您可以拥抱它们以获得彩色日志或禁用它们。

要在 Jenkins 中启用颜色,您可以修改管道定义:

pipeline {
    ...
    options {
        ansiColor('xterm')
    }
    ...
}

这是对AnsiColor插件的引用。

如果你不能使用这个插件并且想在 sbt 日志中禁用颜色,你可以通过修改sbt.color选项来做到这一点。例如,通过启动 sbt -Dsbt.color=false(我看到您可以在 UI 中添加它)或将其添加到SBT_OPTS环境变量中:

pipeline{
    ...
    environment {
        SBT_OPTS = "${SBT_OPTS} -Dsbt.color=false"
    }
    ...
}

查看sbt 文档并查看该sbt.ci选项,它应该在 Jenkins 上自动设置。


推荐阅读