在Jenkins管道上的各个阶段之间传输数据
我是否能够以某种方式将数据从一个阶段复制到另一个阶段上使用 例如,我有一个阶段想克隆我的回购协议,另一个阶段运行Kaniko,它将(在dockerfile上)所有数据复制到容器并构建它 如何做到这一点?因为在Jenkins管道上的各个阶段之间传输数据,jenkins,jenkins-pipeline,pipeline,Jenkins,Jenkins Pipeline,Pipeline,我是否能够以某种方式将数据从一个阶段复制到另一个阶段上使用 例如,我有一个阶段想克隆我的回购协议,另一个阶段运行Kaniko,它将(在dockerfile上)所有数据复制到容器并构建它 如何做到这一点?因为 阶段是独立的,我无法通过两个阶段上的相同数据进行操作 在Kaniko上,我无法安装GIT来克隆它 提前谢谢 代码示例: pipeline { agent none stages { stage('Clone repository') { agent {
- 阶段是独立的,我无法通过两个阶段上的相同数据进行操作
- 在Kaniko上,我无法安装GIT来克隆它 提前谢谢
pipeline {
agent none
stages {
stage('Clone repository') {
agent {
label 'builder'
}
steps {
sh 'git clone ssh://git@myrepo.com./repo.git'
sh 'cd repo'
}
}
stage('Build application') {
agent {
docker {
label 'builder'
image 'gcr.io/kaniko-project/executor:debug'
args '-u 0 --entrypoint=""'
}
}
steps {
sh '''#!/busybox/sh
/kaniko/executor -c `pwd` -f Dockerfile"
'''
}
}
}
}
dockerfile I上的p.S.使用
ADD . /
您可以尝试使用:
stage('Clone repository') {
agent {
label 'builder'
}
steps {
sh 'git clone ssh://git@myrepo.com./repo.git'
script {
stash includes: 'repo/', name: 'myrepo'
}
}
}
stage('Build application') {
agent {
docker {
label 'builder'
image 'gcr.io/kaniko-project/executor:debug'
args '-u 0 --entrypoint=""'
}
}
steps {
script {
unstash 'myrepo'
}
sh '''#!/busybox/sh
/kaniko/executor -c `pwd` -f Dockerfile"
'''
}