詹金斯 -> 来源:未找到

Raj*_*gah 2 jenkins docker

当我通过 ssh 运行此命令到 aws 实例时

docker run hello-world
aws ecr get-login --no-include-email --region ap-south-1 > ./login
source ./login
Run Code Online (Sandbox Code Playgroud)

它输出

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
Run Code Online (Sandbox Code Playgroud)

这就是成功。但是当在詹金斯中输入相同的命令时 在此输入图像描述 输出是 在此输入图像描述

  1. 我通过添加用户

    sudo usermod -a -G docker jenkins
    sudo usermod -a -G docker user
    
    Run Code Online (Sandbox Code Playgroud)

出了什么问题?

Dav*_*aze 6

source不是标准 shell 命令;它不是POSIX.1 规范中的“特殊内置实用程序”之一。有些 shell 碰巧有一个名为 的命令source,但并不要求它存在。

有一个类似的标准命令 .可以在当前 shell 的上下文中执行文件。如果您使用的是特定于 bash 的source,通常可以将其更改为标准,.而无需进行任何进一步的更改

. ./login
Run Code Online (Sandbox Code Playgroud)

注意.搜索$PATH要运行的文件;除非特别告知,否则它不会搜索当前目录。另请注意,您通常仅用于.具有副作用(例如设置环境变量)的脚本,并且在类似于您显示的每个命令在单独的 shell 中运行的上下文中,这不会产生更持久的效果。

由于该命令的输出aws ecr get-login是单个docker login命令,不会直接更改 shell 上下文,因此您也可以将其作为 shell 脚本运行

sh ./login
Run Code Online (Sandbox Code Playgroud)