从多个 SCM 拉取然后将 Concourse CI 中的 mv 文件拉到 workdir

Pull from multiple SCM then mv file in Concourse CI to workdir

我已经在这个问题上苦苦思索了很长一段时间,但我想不通(不过我知道这一定是一件简单的事情)。

目前,我正在尝试做的是从两个存储库中提取数据(这自然会创建两个单独的目录),然后我试图将文件从一个目录移动到另一个目录以成功执行 Dockerfile。

我的 pipeline.yml 文件如下所示:

---
jobs:
- name: build-nexus-docker-image
  public: false
  plan:
  - get: git-nexus-docker-images
    trigger: true
  - get: git-nexus-license
    trigger: true
  - task: mv-nexus-license
    config:
      platform: linux
      image_resource:
        type: docker-image
        source: {repository: ubuntu, tag: "trusty"}
      inputs:
        - name: git-nexus-license
        - name: git-nexus-docker-images
      run:
        path: /bin/sh
        args:
          - -c
          - mv -v git-nexus-license/nexus.lic git-nexus-docker-images/nexus.lic; ls -la git-nexus-docker-images
  - put: nexus-docker-image
    params:
      build: git-nexus-docker-images/

resources:
- name: git-nexus-docker-images
  type: git
  source:
    uri: git@git.company.com:dev/nexus-pro-dockerfile.git
    branch: test
    paths: [Dockerfile]
    private_key: {{git_ci_key}}

- name: git-nexus-license
  type: git
  source:
    uri: git@git.company.com:secrets/nexus-information.git
    branch: master
    paths: [nexus.lic]
    private_key: {{git_ci_key}}

- name: nexus-docker-image
  type: docker-image
  source:
    username: {{aws-token-username}}
    password: {{aws-token-password}}
    repository: {{ecr-nexus-repo}}

我已经发布了实际可以部署到 Concourse 的管道;但是我尝试了很多东西,但我不知道该怎么做。我坚持将许可证文件从 git-nexus-license 目录移动到 git-nexus-docker-images 目录。我所做的似乎没有 mv nexus.lic 文件,因为在构建 docker 图像时它失败了,因为它在目录中找不到该文件。

编辑:我已经成功地 "mv" nexus.lic 使用上面的代码,但是由于找不到文件,构建仍然失败!我不确定我做错了什么,如果我手动构建,构建工作正常,但在 Concourse 中它失败了。

好的,所以我弄清楚了我做错了什么,和往常一样,这是一些小问题。我忘记将 outputs 添加到 yml 文件中,它告诉大厅这是新的工作目录。这是现在的样子(对我有用):

---
jobs:
- name: build-nexus-docker-image
  public: false
  plan:
  - get: git-nexus-docker-images
    trigger: true
  - get: git-nexus-license
    trigger: true
  - task: mv-nexus-license
    config:
      platform: linux
      image_resource:
        type: docker-image
        source: {repository: ubuntu, tag: "trusty"}
      inputs:
        - name: git-nexus-license
        - name: git-nexus-docker-images
      outputs:
        - name: build-nexus-dir
      run:
        path: /bin/sh
        args:
          - -c
          - mv -v git-nexus-license/nexus.lic build-nexus-dir/nexus.lic; mv -v git-nexus-docker-images/* build-nexus-dir; ls -la build-nexus-dir;
  - put: nexus-docker-image
    params:
      build: build-nexus-dir/

resources:
- name: git-nexus-docker-images
  type: git
  source:
    uri: git@git.company.com:dev/nexus-pro-dockerfile.git
    branch: test
    paths: [Dockerfile]
    private_key: {{git_ci_key}}

- name: git-nexus-license
  type: git
  source:
    uri: git@git.company.com:secrets/nexus-information.git
    branch: master
    paths: [nexus.lic]
    private_key: {{git_ci_key}}

- name: nexus-docker-image
  type: docker-image
  source:
    username: {{aws-token-username}}
    password: {{aws-token-password}}
    repository: {{ecr-nexus-repo}}

我希望这对遇到困难的人有所帮助。 :)