jenkins - 我有一个 groovy utils 文件,其中包含一些方法,一种方法如何调用另一种方法
问题描述
是否可以有一个 .groovy 文件,其中定义了一些实用程序函数,并且其中一个函数在该文件中调用另一个函数?
注意:对于上下文,这用于 vars 文件夹下的 Jenkins Pipeline 库。我想让一个用于参数验证的函数在同一个 groovy 脚本文件中调用另一个函数。
即让 someFunction 使用 doSomething 函数,下面是一些伪代码。
//utils.groovy
def doSomething(def a) {
def aPrime = a
if (a == 'somethingSpecial') {
//handle it
//some logic goes here
aPrime = b
}
return aPrime
}
def someFunction(def x) {
y = doSomething(x);
more stuff.. using y
return someResult
}
def dodad() {
...
}
def whatsIt(){
...
}
在我的实际代码中,我收到类似的错误No signature of method: groovysh_evaluate.myCommonFunct() is applicable for argument types: () values: []
解决方案
Nevermind this does work. I got the error when I tried to run the contents of the file locally in groovysh. But no errors when it ran in the Jenkins pipeline
推荐阅读
- git - 如何使用 --theirs 或 --ours 合并大多数冲突?
- .net - .net oracle 插入查询
- android - 如何使用 Delegates.Observable 获得新旧数据之间的差异?
- liquibase - Liquibase:如何为包/功能生成变更日志
- c++ - time() 库函数的返回数据类型
- bash - 应用中心中缺少 xamarin 表单 iOS bash 脚本
- websocket - Parse-server 中的实时查询订阅更新
- rxjs - RxJS 验证结果的存在
- php - 不能在php中做数组方程
- module - windows PowerShell ISE 多脚本(删除-压缩-重命名)