我想使用Jenkins声明性管道和代理语法来构建一个工件,然后将其部署到侧车容器,如下面的伪代码所示:
pipeline {
agent none
stages {
stage('Build Artefact') {
agent { docker 'build-agent' }
steps {
< I want to create the artefact to deploy to a side car container here >
}
}
stage('Deploy Artefact') {
agent { docker 'side-car' }
steps {
< I want to deploy the artefact created in the previous stage here >
}
}
}
}我正在努力解决的是如何将文件从“构建工件”阶段使用的容器传递到“部署工件”阶段使用的容器,据我所知,stash不能跨容器工作,除非有人有其他经验。
根据Jenkins文档,您可以使用args参数为声明性管道语法指定卷:
pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v $HOME/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B'
}
}
}
}然而,我想知道是否有一个更优雅的解决方案,不涉及传递卷。
https://stackoverflow.com/questions/47756969
复制相似问题