jenkins - 在管道步骤之间传递值/数据
问题描述
你好!
我需要在 Jenkins 管道中将数据从一个步骤传递到另一个步骤。像这样的东西:
node {
// myPipelineStep is "my" own hello world pipeline step based on hello-world archetype, and I want it to return a variable that I have inside the plugin
def return_value = myPipelineStep inputVariable: value
// Then I want to do something else, a new step, where I use this value
sh 'echo $return_value'
//But the problem is I dont know how to return something from my pipeline step
}
但是在原型空插件中,应该执行操作的 perform() 函数是无效的。所以这里不可能返回一些东西。
有任何线索的人吗?
解决方案
您可以修改方法中的内容吗?如果是这样,请在外部创建一个全局变量并在方法内部分配值。
现在变量将具有值,您可以在其他方法中使用它,例如
node{
def isVaild
void perform(.....) {
//do stuff
isValid =true;
}
@Override
void perform(.....) {
//do stuff
if(isValid){
}
}
}
它应该工作:)
推荐阅读
- ios - AppCenter 获取模块失败并显示错误 65
- json - 使用 jq 从 json 文件生成模式
- java - Hibernate JPA 元模型——引用嵌套属性?
- integration - Workday 集成错误 - 查询返回的结果过多
- react-native - 尝试在 WSL 上安装 React-Native 需要资源
- c++ - 带有 ODBC 驱动程序的 PostgreSQL“光标未定位在一行上”
- asp.net-core - ASP.NET Core WebAPI XML 方法参数反序列化
- python - 为什么我不断收到 AttributeError:'NoneType' 对象没有属性 'lower'?
- python - 如何使用python循环XML文件中的标签
- python - 如何重定向到 Django 页面上的特定位置?