Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Jenkins凭证(文件)传递给Docker Build Arg_Docker_Jenkins_Jenkins Pipeline - Fatal编程技术网

将Jenkins凭证(文件)传递给Docker Build Arg

将Jenkins凭证(文件)传递给Docker Build Arg,docker,jenkins,jenkins-pipeline,Docker,Jenkins,Jenkins Pipeline,我想将jenkins凭证(机密文件)的内容作为jenkins文件中的build arg传递给docker 正如这里所描述的,我们必须在build arg中对该文件执行cat。但在詹金斯如何做到这一点 --build-arg ssh_key="$(cat ~/.ssh/id_rsa)" Dockerfile ... ARG ssh_key RUN echo "$ssh_key" > /root/.ssh/id_rsa ... ... environ

我想将jenkins凭证(机密文件)的内容作为jenkins文件中的build arg传递给docker

正如这里所描述的,我们必须在build arg中对该文件执行cat。但在詹金斯如何做到这一点

--build-arg ssh_key="$(cat ~/.ssh/id_rsa)"
Dockerfile

...
ARG ssh_key
RUN echo "$ssh_key" > /root/.ssh/id_rsa
...
...
environment {
ssh_key = credentials(ssh_key)
}
...

def build = docker.build(registry,"--build-arg ssh_key= .)
Jenkinsfile

...
ARG ssh_key
RUN echo "$ssh_key" > /root/.ssh/id_rsa
...
...
environment {
ssh_key = credentials(ssh_key)
}
...

def build = docker.build(registry,"--build-arg ssh_key= .)
有什么想法吗