美文网首页
【Jenkins插件】Ansicolor

【Jenkins插件】Ansicolor

作者: 87d6dc4b11a7 | 来源:发表于2024-09-03 13:33 被阅读0次

    1、安装插件

    2、编写Jenkinsfile

    pipeline {
        agent {label 'agent'}
        
        options { skipDefaultCheckout() }
    
    
        stages {
    
            stage('test') {
                steps {
                    script {
                        dir("${WORKSPACE}") {
                            ansiColor('xterm') {
                                // some block
                                echo "\033[32m=======绿色字=======\033[0m"
                                
                                echo "\033[41;30m=======红底黑字=======\033[0m"
    
                                echo "\033[30m=======黑色字=======\033[0m"
                                
                                echo "\033[31m=======红色字=======\033[0m"
                                
                                echo "\033[33m=======黄色字=======\033[0m"
                                
                                echo "\033[46;30m=======天蓝底黑字=======\033[0m"
                                
                                echo "\033[4;31m=======下划线红字=======\033[0m"
                                
                                echo "\033[5;31m=======红字在闪烁=======\033[0m"
    
                            }
                            
                            ansiColor('vga') {
                                // some block
                                echo "\033[32m=======绿色字=======\033[0m"
                                
                                echo "\033[41;30m=======红底黑字=======\033[0m"
    
                                echo "\033[30m=======黑色字=======\033[0m"
                                
                                echo "\033[31m=======红色字=======\033[0m"
                                
                                echo "\033[33m=======黄色字=======\033[0m"
                                
                                echo "\033[46;30m=======天蓝底黑字=======\033[0m"
                                
                                echo "\033[4;31m=======下划线红字=======\033[0m"
                                
                                echo "\033[5;31m=======红字在闪烁=======\033[0m"
                            }
                            
                            ansiColor('css') {
                                // some block
                                echo "\033[32m=======绿色字=======\033[0m"
                                
                                echo "\033[41;30m=======红底黑字=======\033[0m"
    
                                echo "\033[30m=======黑色字=======\033[0m"
                                
                                echo "\033[31m=======红色字=======\033[0m"
                                
                                echo "\033[33m=======黄色字=======\033[0m"
                                
                                echo "\033[46;30m=======天蓝底黑字=======\033[0m"
                                
                                echo "\033[4;31m=======下划线红字=======\033[0m"
                                
                                echo "\033[5;31m=======红字在闪烁=======\033[0m"
                            }
                        }
                    }
                }
            }
        }
    }
    

    3、运行,输出效果:

    image.png

    参考:
    https://plugins.jenkins.io/ansicolor/

    相关文章

      网友评论

          本文标题:【Jenkins插件】Ansicolor

          本文链接:https://www.haomeiwen.com/subject/vxvkljtx.html