Behave test runner has no colored output on Jenkins

I have setup jenkins on Ubuntu server 14.04 on an EC2 instance. I have some selenium tests that I execute using behave as test runner.

On Jenkins I have also installed the plugin AnsiColor hoping that I can get color output on the jenkins console, however I get color for everything else except for the Gherking syntax. Selenium errors, python debug, everything has color... except for the output of behave.

Now the thing is if I run the tests on a Mac or on Ubuntu but not with the Jenkins user, everything works fine and the colors are there.

I really don't have any code to post, but I can say what I have tried to no avail:

  • running behave with behave --color
  • mapping the color map of AnsiColorPlugin to the escape sequences of behave found in formatter/ansi_escapes.py
  • adding #!/bin/bash to jenkins build script to make sure it does not get executed with sh instead of bash
  • If this is of any relevance I am using python 3.4 on virtualenv

    Besides the actual answer, any suggestions on how to debug this are also welcome! thanks


    Reading original source code of PrettyFormatter , there's no way to force it to use colors as it uses isatty to determine if it's writing to actual terminal.

    However, necessary modifications to enable color output are trivial:

    https://github.com/mrkafk/behave/commit/5fa2dd3fd1dc7149857df4da156d8fd00f5058a5

    I've created pull request and tested it to work in Jenkins (after enabling parsing ANSI codes in project configuration of course):

    在这里输入图像描述

    链接地址: http://www.djcxy.com/p/27032.html

    上一篇: 从GitHub仓库下载单个文件夹或目录

    下一篇: 在Jenkins上Behave test runner没有彩色输出