jenkins - Jenkins 更新后使用 AnsiColorBuildWrapper 在控制台输出中不再有颜色
问题描述
由于我们已更新到 Jenkins 版本 2.235.1,因此在使用 AnsiColorBuildWrapper 时,控制台输出中的颜色无法正确显示。这使得获得 Ansible 输出的正确概览变得更加困难。
我们的 Jenkins 工作流程中的片段
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
println(("\033[31m ************************** ${role} wird ausgerollt *************************** \033[0m"))
}
configFileProvider([configFile(fileId: '1609a7e4-2674-4cef-9945-db9492f2dcd6', variable: 'vaultPassWord')]) {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
ansiblePlaybook colorized: true, credentialsId: 'app-serveraccess-user',
extras: "--extra-vars='env=${currentStage}' --extra-vars='workspace=${workspace}' --extra-vars='app=${app}' -l ${hostname.toLowerCase()} --vault-password-file ${env.vaultPassWord} ${debug_ansible}", installation: 'Ansible',
inventory: '/vol1/ansible/hosts', playbook: "/etc/ansible/playbooks/${role}/${role}_config.yml",
sude: true, sudoUser: null
}//wrap
}//configFileProvider
控制台输出中的结果:
[159] $ sshpass ******** /usr/bin/ansible-playbook /etc/ansible/playbooks/app/app_config.yml -i /vol1/ansible/hosts -u devadmin -k --extra-vars=env=oat --extra-vars=workspace=/vol1/jenkins/jobs/SERVER-CONFIG-WF/pipeline/159 --extra-vars=app=app -l server-app-r0001.com --vault-password-file /vol1/jenkins/jobs/SERVER-CONFIG-WF/pipeline/159@tmp/config1179695197260634236tmp --diff
17:02:25 [0;35m[DEPRECATION WARNING]: DEFAULT_SUDO_EXE option, In favor of become which is a [0m
17:02:25 [0;35mgeneric framework . This feature will be removed in version 2.8. Deprecation [0m
17:02:25 [0;35mwarnings can be disabled by setting deprecation_warnings=False in ansible.cfg.[0m
17:02:25 [0;35m[DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a [0m
17:02:25 [0;35mgeneric framework . This feature will be removed in version 2.8. Deprecation [0m
17:02:25 [0;35mwarnings can be disabled by setting deprecation_warnings=False in ansible.cfg.[0m
17:02:25 [1;35m [WARNING]: Found both group and host with same name: localhost[0m
你现在看到的不是颜色,而是 python 用来在控制台上创建它们的控制字符串
所有插件都是最新的
我们能做些什么来解决这个问题?
解决方案
推荐阅读
- php - 如何避免for循环中的mysql查询
- apache-kafka - Kafka - 消息排序保证
- python - 如何使用 python 更改我的不和谐机器人的音量?
- python - 在 Flask App 而不是在烧瓶外壳中运行时出现 NameError
- apache-spark - 如何将数据从 PySpark 持久化到 Hive - 避免重复
- time - 计算仅包含时间的单元格
- microsoft-cognitive - Azure JavaScript TTS-SDK 用于将结果作为内存流 ERROR
- node.js - 使用 Amazon AWS 将 React、Node/Express 和 MySQL Web 应用程序部署到 Web 上
- dns - 为单个域使用多个邮件服务器
- ios - TableView Cell 沿 y 轴的缩放比例不同