大厅资源 - 任务输出无法放置

concourse resource - task output not available to put

如何 puttaskoutput 转换为资源?

  - name: build-pkg-rpm
    public: true
    plan:
    - aggregate:
      - get: oregano-test-fedora
      - get: git-clone-resource
        trigger: true
        passed: [compile, build-docker-image-fedora]

    - task: create-rpm
      image: oregano-test-fedora
      config:
        platform: linux
        inputs:
        - name: git-clone-resource
        outputs:
        - name: srpm
          path: ../srpm
        run:
          path: .concourse/fedora/buildrpm.sh
          dir: git-clone-resource

    - put: srpm
      resource: copr-resource
      params:
        rpmbuild_dir: "srpm/rpmbuild/SRPMS"
        chroots: ["mageia-6-x86_64", "mageia-couldron-x86_64", "fedora-rawhide-x86_64", "fedora-25-x86_64"]
        enable_net: false
        max_n_bytes: 250000000
        project_id: 825
        regex: ".*oregano-.*\.src\.rpm$"

buildrpm.sh

#!/usr/bin/env bash

set -e
set -x

pwd 2>&1
RPMBUILD_DIR="$(pwd)/../srpm/rpmbuild/"
mkdir -p ${RPMBUILD_DIR}/{SOURCES,BUILD,RPMS,SRPMS,SPECS}

# fill all vars of the spec.in
./waf configure rpmspec
cp -v build/rpmspec/oregano.spec ${RPMBUILD_DIR}/SPECS/

# generate the distributable tar
./waf dist
cp -v oregano*.tar.xz ${RPMBUILD_DIR}/SOURCES/

cd ${RPMBUILD_DIR}
rpmbuild \
--define "_topdir %(pwd)" \
--define "_builddir %{_topdir}/BUILD" \
--define "_rpmdir %{_topdir}/RPMS" \
--define "_srcrpmdir %{_topdir}/SRPMS" \
--define "_specdir %{_topdir}/SPECS" \
--define "_sourcedir  %{_topdir}/SOURCES" \
-ba SPECS/oregano.spec && echo "RPM was built"
pwd 2>&1

根据

https://github.com/starkandwayne/concourse-tutorial/tree/master/12_publishing_outputs

这应该可以,但是放置步骤中的目录是空的。

文档 https://concourse-ci.org/put-step.html 似乎没有太多涉及这个主题。

我看到文件写入正确:

Wrote: /tmp/build/be0f50d1/srpm/rpmbuild/SRPMS/oregano-0.84.3-1.fc25.src.rpm Wrote: /tmp/build/be0f50d1/srpm/rpmbuild/RPMS/x86_64/oregano-0.84.3-1.fc25.x86_64.rpm Wrote: /tmp/build/be0f50d1/srpm/rpmbuild/RPMS/x86_64/oregano-debuginfo-0.84.3-1.fc25.x86_64.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.6mO3iF
+ umask 022
+ cd /tmp/build/be0f50d1/srpm/rpmbuild/BUILD
+ cd oregano
+ rm -rf /tmp/build/be0f50d1/srpm/rpmbuild/BUILDROOT/oregano-0.84.3-1.fc25.x86_64
+ exit 0
+ echo 'RPM was built' RPM was built RPM was built
+ pwd /tmp/build/be0f50d1/srpm/rpmbuild

但是当涉及到 put 任务的 output 时,它没有找到任何文件:

base dir: "/tmp/build/put/srpm/rpmbuild/SRPMS"
error: Could not find any matches with that regex
caused by: WalkDir entry is useless
caused by: IO error for operation on /tmp/build/put/srpm/rpmbuild/SRPMS: No such file or directory (os error 2)
caused by: No such file or directory (os error 2)

当我劫持到容器中时:

1: build #136, step: create-rpm, type: task
2: build #136, step: srpm, type: put

选择容器:1

[root@f004c6a0-adee-4735-792f-8e237f645751 be0f50d1]# ls -al
total 0
drwxr-xr-x. 1 root root  44 May 31 11:43 .
drwxr-xr-x. 1 root root  24 May 31 11:43 ..
drwxr-xr-x. 1 root root 598 May 31 11:43 git-clone-resource
drwxr-xr-x. 1 root root  16 May 31 11:43 srpm
[root@f004c6a0-adee-4735-792f-8e237f645751 be0f50d1]# ls -al srpm/rpmbuild/
BUILD/     BUILDROOT/ RPMS/      SOURCES/   SPECS/     SRPMS/     
[root@f004c6a0-adee-4735-792f-8e237f645751 be0f50d1]# ls -al srpm/rpmbuild/
BUILD/     BUILDROOT/ RPMS/      SOURCES/   SPECS/     SRPMS/     
[root@f004c6a0-adee-4735-792f-8e237f645751 be0f50d1]# ls -al srpm/rpmbuild/SRPMS/
total 1232
drwxr-xr-x. 1 root root      58 May 31 11:43 .
drwxr-xr-x. 1 root root      70 May 31 11:43 ..
-rw-r--r--. 1 root root 1260666 May 31 11:43 oregano-0.84.3-1.fc25.src.rpm

选择容器:2

/tmp/build/put # ls -al
total 0
drwxr-xr-x    1 root     root            82 May 31 11:43 .
drwxr-xr-x    1 root     root             6 May 31 11:43 ..
drwxr-xr-x    1 root     root           414 May 31 11:31 git-clone-resource
drwxr-xr-x    1 root     root           130 May 23 07:25 oregano-test-fedora
drwxr-xr-x    1 42949672 42949672         0 May 31 11:43 srpm
/tmp/build/put # #ls -al srpm/
/tmp/build/put # #ls -al srpm/
/tmp/build/put # #ls -al ../srpm
/tmp/build/put # ls -al ../srpm
ls: ../srpm: No such file or directory
/tmp/build/put # ls -al srpm
total 0
drwxr-xr-x    1 42949672 42949672         0 May 31 11:43 .
drwxr-xr-x    1 root     root            82 May 31 11:43 ..

那么为什么在 put 步骤中文件结构和 oregano-*.src.rpm 都不可用?

完整的 YAML 大厅在这里可用,但据我所知没有必要 https://github.com/drahnr/oregano/blob/master/.concourse.yml

问题是这样的:

- task: create-rpm
  image: oregano-test-fedora
  config:
    platform: linux
    inputs:
    - name: git-clone-resource
    outputs:
    - name: srpm
      path: ../srpm

path: ../srpm 将输出放在卷外,因此内容丢失了。请注意,dir 不会对 inputsoutputs 做任何事情,只是更改脚本执行的工作目录!

默认值就足够了,等于 path: srpm(或 path: ""

这个有效:

- task: create-rpm
  image: oregano-test-fedora
  config:
    platform: linux
    inputs:
    - name: git-clone-resource
    outputs:
    - name: srpm