gpt4 book ai didi

java - 大厅 CI + MVN

转载 作者:行者123 更新时间:2023-12-01 17:46:40 24 4
gpt4 key购买 nike

我正在尝试使用 Maven 使用 Concourse CI 创建管道。管道应该:

  • 从 git 获取代码。
  • 使用 Maven 构建并运行测试。
  • 项目在目标文件夹中生成 html 报告

以上步骤执行正常。问题是如何访问maven项目生成的输出即目标文件夹。

我无法访问生成的文件夹并复制到所需的文件夹以供以后使用。

文件 pipeline.yml:

resources:
- name: branch-master
type: git
source:
uri: {{git-url}}
branch: master

jobs:
- name: MavenJob
serial: true
plan:
- get: branch-master
trigger: true
- task: mvn-test
privileged: true
file: branch-dev/AppDemo/test.yml

文件 test.yml:

platform: linux

image_resource:
type: docker-image
source:
repository: maven
tag: latest

inputs:
- name: branch-master
outputs:
- name: mvn-output

run:
path: "mvn"
args: ["-f", "branch-master/AppDemo/pom.xml", "test"]

请有人帮助我。

提前致谢。

最佳答案

为了简单和明确起见,我将您的 git 存储库重命名为 project。我们假设它包含大厅的 yaml。并且有一个目录AppDemo,其中包含java-maven app

项目/pipeline.yml:

resources:
- name: project
type: git
source:
uri: {{git-url}}
branch: master

jobs:
- name: MavenJob
serial: true
plan:
- get: project
trigger: true
- task: mvn-test
privileged: true
file: project/test.yml

上面的作业应该找到并触发 test.yml 任务

项目/test.yml:

platform: linux

image_resource:
type: docker-image
source:
repository: maven # let's hope bin/bash is available there. if no, use sh
tag: latest

inputs:
- name: project # project is your git-repo. all paths are relative to it's location
outputs:
- name: mvn-output

run:
path: /bin/bash
args:
- project/test-script.sh:

项目/test-script.sh:

_ROOT=$(pwd)
echo "starting test-script from directory: $ROOT"

cd _ROOT/AppDemo
mvn test

如果您想将 Maven 作业的输出传递到更远的地方,那么您应该将所有这些文件复制到脚本稍后的 mvn-output 目录中。

我还建议使用这个 bash 脚本作为包装器,而不是原始的“maven 调用”——它更方便调试整个过程,例如回显路径。

如果出现任何错误,如果容器仍然存在,请尝试劫持它以查看那里实际发生了什么以及文件所在的位置:

fly -t <target> hijack -u <url-of-failed-job-from-your-browser>

希望这有帮助

关于java - 大厅 CI + MVN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60856289/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com