貌似每个 stage 中的shell 环境不是同一个
我这样写的
在第二个stage 里面, build image, 无法使用docker 命令, 在第一个stage 里面 module add 了
在第二个stage 里面还是不能用. 除非把两个上面的module add 和 docker 命令放在一起, 才可以.
如何在多个stage 里面共享同一个shell 环境呢. 后面还有很多stage 都要用到?
请大家帮忙解答一下
pipeline{
agent {label "GENERAL"}
options{
timestamps()
}
stages{
stage("prepare environment"){
steps(){
echo "prepare the environmen
sh '''
cd $WORKDIR
set +x
. /app/modules/4/init/$(basename $BASH) -x
module add docker/20.10.6
module add twic/0.1.8
module add git/2.35.1
'''
}
}
stage("build image"){
steps(){
echo "build the image"
sh '''
cd $WORKDIR
docker image build -t $IMAGE:$TAG .
'''
}
}
}
}