且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用作业DSL执行python脚本throgh groovy脚本

更新时间:2023-12-05 14:26:10

Jenkins DSL'python'指的是发光熊猫" 插件不是 python脚本插件.如果像我一样使用python脚本插件,则应牢记这一点.

Jenkins DSL 'python' refers to the Shining Panda plugin not the python script plugin. This is worth bearing in mind if like me you use the python script plugin.

可悲的是python脚本插件没有API,但是您可以使用configure闭包直接添加此代码.

Sadly the python script plugin doesn't have an API but you can use a configure closure to add this direct.

configure { node ->
  node / builders / 'hudson.plugins.python.Python' / command << readFileFromWorkspace('<script location>')
}

对于我来说,这很简单,我想从脚本中读取内容,或者您​​可以直接添加'command('import os')'

This has worked for me as I like to read from script for simplicity or you could add direct with 'command( 'import os' )'