在jenkins中运行python脚本

问题描述 投票:0回答:1

我想使用Jenkinsfile从Jenkins运行python脚本。有什么办法可以直接从Jenkinsfile运行它。

我在Jenkins中找到了python插件Click Here)来运行脚本,但是此插件没有适当的文档。如果有人解释如何将此插件与Jenkinsfile集成,这将非常有帮助。

python jenkins jenkins-pipeline jenkins-plugins
1个回答
0
投票

[具有在构建步骤中执行python脚本的功能。以外该插件的工作原理与标准Shell脚本非常相似支持

根据插件的文档。尽管我没有通过管道使用此插件,但从工作的角度来看,您只需要提供.py脚本(文件名和路径),就如同提供shell / powershell脚本一样即可。

类似地,即使对于python,您也将在Linux或Windows的节点上执行脚本。

因此,它的工作方式如下:

stage('build') {
    steps {
        sh 'python abc.py'
    }
}

参考:https://www.jenkins.io/doc/pipeline/tour/hello-world/

查找“ Python”块。

© www.soinside.com 2019 - 2024. All rights reserved.