Jenkins 子业务日志拆分分析方法

需求

Jenkins日志打印内容很长,或者并发编译导致,日志内容不容易查看。

对于具体业务失败, 开发者希望看到具体业务自身的日志内容。

 

解法

tee 命令能够保证, shell命令执行的内容,即往控制台输出,又往文件输出,满足了第一个要求,业务日志单独输出。

https://blog.csdn.net/liu_zhen_wei/article/details/18010709

echo "ABCD" | tee temp.txt temp02.txt

将输出内容"ABCD"同时重定向到 temp.txt 和 temp02.txt 并且在终端打印输出

 

echo "ABCD" | tee -a temp.txt

将输出内容"ABCD"重定向追加到 temp.txt同时在终端打印输出

 

archiveArtifacts 指令

https://jenkins.io/doc/pipeline/tour/tests-and-artifacts/

 

When there are test failures, it is often useful to grab built artifacts from Jenkins for local analysis and investigation. This is made practical by Jenkins’s built-in support for storing "artifacts", files generated during the execution of the Pipeline.

This is easily done with the archiveArtifacts step and a file-globbing expression, as is demonstrated in the example below:

此指令可以将关注的文件,打包保存在Jenkins系统上,跟具体的构建关联起来。

Jenkinsfile (Scripted Pipeline)

node {
    try {
        stage('Test') {
            sh './gradlew check'
        }
    } finally {
        archiveArtifacts artifacts: 'build/libs/**/*.jar', fingerprint: true
        junit 'build/reports/**/*.xml'
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值