从 jenkins 管道运行 python 脚本并获取其返回值

时间:2021-07-27 15:29:18

标签: python jenkins groovy jenkins-pipeline

所以我有 jenkins 管道,我正在以这种方式运行我的 python script

stage('Running python script') {
            steps {
                echo "Run script"
                bat "python D:\\srcipt.py --n 10"
                }
        }

所以这个脚本运行,我可以看到它打印的所有行,但我也想得到它返回的``。

有可能吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用 returnStdout:true 选项。 它看起来像

def result = bat script: "python D:\\srcipt.py --n 10", returnStdout: true
相关问题