Jenkins声明式管道调用方法阶段

问题描述

目标

我正在尝试创建配置略有不同的多个docker映像,这些将构成进一步构建的不同构建的基础。为了避免代码重复,我尝试在声明性管道中使用一个方法

问题

我不知道如何拥有其中包含多个pipeline{ agent any stages{ stage('Create Images'){ parallel { stage('Image Foo'){ environment{ dockerImage='' } stages{ stage("Build image"){ steps{ scripted{ dockerImage=docker.build(...) } } } stage("Configure image"){ configImage(dockerImage) } stage('Push to artifactory'){ steps{ scripted{ dockerImage.push() dockerImage.push("latest") } } } } } stage('Image Bar'){ environment{ dockerImage='' } stages{ stage("Build image"){ steps{ scripted{ dockerImage=docker.build(...) } } } stage("Configure image"){ configImage(dockerImage) } stage('Push to artifactory'){ steps{ scripted{ dockerImage.push() dockerImage.push("latest") } } } } } } } } } void configImage(dockerImage){ stages{ stage("Grab some files"){ steps{ echo "I'm getting some files" } } stage("Install some stuff"){ steps{ echo "Install all the things" } } } } 方法

示例

nswag aspnetcore2openapi /assembly:CT.distanceCalculator /output:openapi.json

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)