How to get stdout and stderr from single Jenkins Pipeline parallel blocks?

◇◆丶佛笑我妖孽 提交于 2019-12-04 03:33:47

问题


I'm using a parallel block into my Jenkinsfile to execute concurrently some tests, but all the outputs are getting mixed up.

This is an extract of my Jenkinsfile, as an example:

// do some IT against different databases
stage name: 'IT'

parallel (
    mysqlIT: {
        node {
            executeMysqlIT()
        }
    },
    oracleIT: {
        node {
            executeOracleIT()
        }
    }
)

Please note that, as suggested here I'm running a new node within each parallel, so they get properly parallelized and each of them gets its own workspace.

What should I do to have Jenkins show me separated outputs for the parallel blocks?


回答1:


On the build page of your job there is a link "Pipeline steps" on the left. There in the tree-like structure you can find all the steps that your job has run including parallel ones. You can go inside of every step and access its console log using the link on the left. Alternatively you can use a "terminal" icon on the right in the same row.

Click it and you will see the console log which solely produced within that step without any intermixing with other steps running simultaneously. If a step or several parallel steps are still in progress their logs will be dynamically updated on each of their console log pages.




回答2:


https://stackoverflow.com/a/58050883/8380249 provides a way to get logs from parallel blocks

  • either as a string in the pipeline code
  • or saved as an artifact of the run

the library used there also provides accessors to the internal ids which I think could be used to generate links to "pipeline steps" files



来源:https://stackoverflow.com/questions/37048239/how-to-get-stdout-and-stderr-from-single-jenkins-pipeline-parallel-blocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!