大厅任务输入文件夹为空

Concourse task input folder is empty

我正在尝试构建一个基于 gradle 的 java 应用程序。我的管道如下所示:

---
resources:
- name: hello-concourse-repo
  type: git
  source:
    uri: https://github.com/ractive/hello-concourse.git

jobs:
- name: gradle-build
  public: true
  plan:
  - get: hello-concourse-repo
    trigger: true
  - task: build
    file: hello-concourse-repo/ci/build.yml
  - task: find
    file: hello-concourse-repo/ci/find.yml

build.yml 看起来像:

---
platform: linux

image_resource:
  type: docker-image
  source:
    repository: java
    tag: openjdk-8

inputs:
- name: hello-concourse-repo
outputs:
- name: output

run:
  path: hello-concourse-repo/ci/build.sh

caches:
- path: .gradle/

和 build.sh:

#!/bin/bash

export ROOT_FOLDER=$( pwd )
export GRADLE_USER_HOME="${ROOT_FOLDER}/.gradle"

export TERM=${TERM:-dumb}
cd hello-concourse-repo
./gradlew --no-daemon build

mkdir -p output
cp build/libs/*.jar output
cp src/main/docker/* output
ls -l output

最后 find.yml

---
platform: linux

image_resource:
  type: docker-image
  source: {repository: busybox}

inputs:
- name: output

run:
  path: ls
  args: ['-alR']

bash.sh 脚本末尾的 ls 输出显示输出文件夹包含预期文件,但查找任务仅显示空文件夹:

我在查找任务中用作输入的 output 文件夹是空的,我做错了什么?

完整的示例可以在 here ci 子文件夹中的 concourse 文件中找到。

你还在 hello-concourse-repo 里面,需要 output 上一层。

你需要记住一些事情:

  1. 您的任务有一个初始工作目录,我们称它为“.”。 (除非您指定“dir”)。在这个初始目录中,您将找到一个包含所有输入和输出的目录。

    ./hello-concourse-repo
    ./output
    
  2. 声明输出时,无需从脚本创建文件夹'output',它会自动创建。

  3. 如果您导航到脚本中的其他文件夹,您需要return到初始工作目录或使用相对路径查找其他文件夹。

您将在下面找到更新后的脚本,其中包含一些解决问题的注释:

#!/bin/bash

export ROOT_FOLDER=$( pwd )
export GRADLE_USER_HOME="${ROOT_FOLDER}/.gradle"

export TERM=${TERM:-dumb}
cd hello-concourse-repo #You changed directory here, so your 'output' folder is in ../output
./gradlew --no-daemon build

# Add this line to return to the initial working directory or use ../output or $ROOT_FOLDER/output when compiling.

#mkdir -p output <- This line is not required, you already defined an output with this name

cp build/libs/*.jar ../output
cp src/main/docker/* ../output
ls -l ../output

由于您正在定义 ROOT_FOLDER 变量,因此您可以使用它进行导航。