Concourse 将任务放入 docker-图像资源。 Build_args 未传递到 Dockerfile

Concourse put task into docker-image resource. Build_args are not passed to Dockerfile

我遇到以下 Concourse 管道 build_args 不是 used/passed 到 docker 构建阶段的情况。管道如下所示:

 name: project
  type: git
  check_every: 1m
  source:
    uri: ((project-url))
    branch: ((project-branch))
    private_key: ((github-private-key))
    paths: [ ((context))/* ]

- name: registry
  type: docker-image
  source:
    username: ((art_user))
    password: ((art_token))
    repository: docker.artifactory......

... ...

jobs:

- name: publish
  serial: true
  plan:
  - in_parallel:
    - get: project
     ... ...
  - put: build
    resource: registry
    params:
      build: project/((context))
      build_args:
        a_user: ((art_user))
        a_token: ((art_token))
        testArg: "testing"

上下文目录中的 Dockerfile 具有以下内容。 我从中删除了任何细节。

FROM docker.artifactor.../debian:buster

#####################

ARG a_user
ARG a_token
ARG testArg
RUN echo "a_user: $a_user"
RUN echo "a_token: $a_token"
RUN echo "testArg: $testArg"
RUN env

问题是这些变量在构建期间具有空值。 下面是一个示例 运行:

Status: Downloaded newer image for docker.artifactory..../debian:buster
 ---> 26a2b081e032
Step 4/38 : ARG a_user
 ---> Running in 6d48933458d9
Removing intermediate container 6d48933458d9
 ---> d2913609be9e
Step 5/38 : ARG a_token
 ---> Running in 1b94c1795d8c
Removing intermediate container 1b94c1795d8c
 ---> 8bc2f65677ca
Step 6/38 : ARG testArg
 ---> Running in 88c088363349
Removing intermediate container 88c088363349
 ---> 810a481ad166
Step 7/38 : RUN echo "a_user: $a_user"
 ---> Running in 901423ea11b6
a_user: 
Removing intermediate container 901423ea11b6
 ---> 58e18ab30dbc
Step 8/38 : RUN echo "a_token: $a_token"
 ---> Running in 95e9239bbceb
a_token: 
Removing intermediate container 95e9239bbceb
 ---> ce2df5ea1a36
Step 9/38 : RUN echo "testArg: $testArg"
 ---> Running in 7443e6da424e
testArg: 
Removing intermediate container 7443e6da424e
 ---> 46ab83d6f94f
Step 10/38 : RUN env
 ---> Running in 4f780b89f7ee
no_proxy=...
HOSTNAME=1f790b89f7ea
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/

你能帮忙吗

你粘贴的管道被编辑得太多了,我无法指出到底出了什么问题,但我注意到一件事是图像资源被命名为 'registry' 但 put 指的是 build资源(?!)。 registryresource 参数引用,which doesn't seem to be a legit param

原路返回。使用以下最小可行管道设置作为指南:

code-repo/docker/Dockerfile

给出以下 dockerfile
FROM ubuntu:bionic

ARG HELLO
RUN echo $HELLO
RUN sleep 100

和如下所示的最小管道:

resources:
  - name: code-repo
    type: git
    source:
      branch: main
      uri: git@gitlab.com:my/repo.git
      private_key: ((repo_key))

  - name: my-docker-image
    type: docker-image
    source:
      repository: oozie/my-docker-image
      tag: latest
      username: ((docker_username))
      password: ((docker_password))


jobs:
  - name: publish-image
    plan:
    - get: code-repo
    - put: my-docker-image
      params:
        build: code-repo/docker
        build_args:
          HELLO: world

我在构建中看到了我的 HELLO 构建参数: