GitLab responseStatus=400 错误请求 FATAL:参数无效 ERROR:作业失败:退出代码 1

GitLab responseStatus=400 Bad Request FATAL: invalid argument ERROR: Job failed: exit code 1

提问人:PatPanda 提问时间:10/25/2023 最后编辑:jonrsharpePatPanda 更新时间:10/26/2023 访问量:107

问:

我正在尝试使用 GitLab 工件 dotenv 文件

在我的 GitLab CI YAML 文件中,我编写了以下代码块:

stages:
  - build

build:
  image: maven:3.9.5-sapmachine-21
  stage: build
  script:
    - mvn clean install spring-boot:run
  artifacts:
    reports:
      dotenv: build.env

在构建日志中,我看到以下内容:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  39.144 s
[INFO] Finished at: 2023-10-25T12:07:22Z
[INFO] ------------------------------------------------------------------------
Uploading artifacts for successful job
Uploading artifacts...
build.env: found 1 matching files and directories  
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/7/artifacts: 400 Bad Request (Invalid Format)  id=7 responseStatus=400 Bad Request status=400 token=64_BFV8L
WARNING: Retrying...                                context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/7/artifacts: 400 Bad Request (Invalid Format)  id=7 responseStatus=400 Bad Request status=400 token=64_BFV8L
WARNING: Retrying...                                context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/7/artifacts: 400 Bad Request (Invalid Format)  id=7 responseStatus=400 Bad Request status=400 token=64_BFV8L
FATAL: invalid argument                            
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

如何使用 dotenv 文件?

maven gitlab-ci dotenv

评论

0赞 sytech 10/26/2023
您的文件包含哪些内容?它们是否符合 dotenv 报告文档中规定的规则/限制?build.env

答:

1赞 sytech 10/26/2023 #1

文件内容的格式不正确。您需要确保该文件是格式正确的 dotenv 文件,并且还遵守 dotenv 报告文档中指定的附加限制。该文档还包含如何正确使用此功能的示例。build.env

如果需要使用不符合此规范的 dotenv 文件,则始终可以将该文件作为普通工件文件传递到其他作业:

# ...
  artifacts:
    paths:
      - build.env

然后,作业应该会收到这个项目,你可以使用你想要的 dotenv 文件的任何工具来使用它们。

评论

0赞 PatPanda 10/26/2023
这是正确的,非常感谢