Jenkins Pipeline - 如何在并行执行后获取值

Jenkins Pipeline - how to get values after parallel execution

是否可以在并行执行期间保存一些值并在最后一步使用这些值?

在下面的例子中,我想知道在并行执行过程中使用了哪个jenkins slave,并在最后一步使用它。

node {
    stage 'Checkout'
    checkout([...])
    stash includes: '**', name: 'binary'

    stage 'Running simulation'
    parallel (
        "stream 1" : { 
                         node {
                                unstash "binary"
                                sh "echo \"$(whoami)@$(hostname):$PWD\""
                                // How to save the previous result

                                // Run simulation on node first slave
                                ...
                           } 
                       },
        "stream 2" : { 
                         node {             
                                unstash "binary"
                                sh "echo \"$(whoami)@$(hostname):$PWD\""
                                // How to save the previous result

                                // Run simulation on node second slave
                                ...
                           } 
                       }
              )


    stage 'Gathering results files'
    // use the values of the slaves to retrieve some files.

    stage 'Generate report'

}

感谢您的回答。

糟糕,我使用的是 2.3 版本的管道节点和进程插件。它适用于 2.5

版本
hostname = sh (returnStdout: true, script: 'hostname')
println hostname