Nay*_*iya 5 python jenkins jenkins-pipeline
我有一个通用的 python 脚本,需要在多个管道作业中使用。我所做的是使用如下通用方法创建一个 qroovy 文件。
def create_slaves()
{
def cmd = 'python "-u my_script.py'
def proc = cmd.execute()
proc.waitfor()
}
return this
Run Code Online (Sandbox Code Playgroud)
执行抛出了这个异常。
Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods execute java.lang.String
Run Code Online (Sandbox Code Playgroud)
所以我觉得这不是正确的做法。有人知道在管道中执行常见 python 脚本的合适方法吗?
使用詹金斯共享库并使用sh其中的步骤。
顺便说一句,也许您的实际用例比您共享的内容更加微妙(在这种情况下,当然,使用共享库),但我想我只需使用sh每个 Jenkinsfile 中的步骤,就像这样,并保留很简单:
pipeline {
agent { label 'docker' }
stages {
stage('build') {
steps {
sh 'python -u my_script.py'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14131 次 |
| 最近记录: |