栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何从Jenkins文件中调用Groovy脚本?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何从Jenkins文件中调用Groovy脚本?

如果

Jenkinsfile
要从外部文件中获取可用的方法,则需要执行以下操作

在您的中

file1.groovy
,返回对方法的引用

def firstTest() {    // stuff here}def testTwo() {    //more stuff here}...return [    firstTest: this.&firstTest,    testTwo: this.&testTwo]

EDIT

evaluate
does not seem to be required

def externalMethod = evaluate readFile("file1.groovy")

or

def externalMethod = evaluate readTrusted("file1.groovy")

And as mentioned by @Olia

def externalMethod = load("file1.groovy")

should work

Here is a reference on

readTrusted
. 请注意,不允许使用
参数替换(进行轻量级签出)

从轻量级结帐:

如果选择此选项,请尝试直接从
SCM 获取管道脚本内容,而不执行完整的检出。这种模式的优点是
效率高。但是,您将不会获得基于
SCM的任何更改日志或轮询。(如果在构建过程中使用checkout scm,则将填充
变更日志并初始化轮询。)
在这种模式下,构建参数也不会替换为SCM配置。仅选定的SCM插件
支持此模式。

至少对我有用



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/636612.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号