在时髦的jenkins pipline中跨多个sh调用持久化shell

问题描述

我在Jenkins管道中有两个常规功能,它们一起登录到ECR存储库并构建了一个docker容器。看起来像这样:

def login() {
    sh "aws ecr get-login --registry-ids <id> --region <region> --no-include-email"
    sh "aws ecr get-login --region <region> --no-include-email"
}

def build(project,tag) {    
    login()
    sh "docker build -t ${project}:${tag} ."
}

但是,当我运行此命令时,我得到pull access denied,好像从未登录过。我推测这是因为aws ecr登录命令在其自己的shell中运行,而build命令在另一个shell中运行。理想情况下,我想利用这种功能分解和groovy的其他功能,但是要在一个进程/ shell中运行shell命令。这可能吗?我该怎么做?

解决方法

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

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

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