我正在使用Elasticbeanstalk部署Dockerfile
我的Dockerfile应该具有
ARG imageTag
FROM xxxxx.dkr.ecr.us-east-2.amazonaws.com/xxxxxx/xxxx:$imageTag
EXPOSE 44444 44440
然后我发现我无法执行'eb init -p docker --build-arg
所以我决定使用sed
因此,我从仓库中提取了修改为的Dockerfile
FROM xxxxx.dkr.ecr.us-east-2.amazonaws.com/xxxxxx/xxxx:imageTag
EXPOSE 44444 44440
然后做
sh('sed -i s/imageTag/$imageTag/g Dockerfile;cat Dockerfile')
我在猫中看到它用参数替换了imageTag,但是当它到达eb init -p docker时,它失败了,
来自守护程序的响应:找不到xxxxx.dkr.ecr.us-east-2.amazonaws.com/xxxxxx/xxxx:imageTag的清单,即它试图从带imageTag标签的ecr中拉出吗?
谁能告诉我为什么?它会将Dockerfile读入内存还是在git checkout上读取内容?
谢谢
所以管道现在是
pipeline {
agent any
stages {
stage ('Checkout') {
steps {
git(
url: 'https://github.com/xxxxx/xxxx.git ',
credentialsId: 'xxxxx',
branch: "master"
)
}
}
stage ('Image Choose') {
steps {
sh('sed -i s/imageTag/$imageTag/g Dockerfile;cat Dockerfile')
}
}
stage('EB terminate') {
steps {
script {
withAWS(credentials:'xxxxx') {
try {
sh('eb terminate --force $environmentName ')
}
catch (Exception e) {
}
}
}
}
}
stage('EB docker init') {
steps {
script {
withAWS(credentials:'xxx') {
sh('eb init -p docker -k $keyName xxxx')
}
}
}
}
stage('EB docker deploy') {
steps {
script {
withAWS(credentials:'xxxx') {
sh('eb create $environmentName ')
}
}
}
}
stage('EB docker open') {
steps {
script {
withAWS(credentials:'xxxx ') {
sh('eb open ')
}
}
}
}