4

一切准备就绪后,我意识到JHipster不再有Dockerfile并且打包使用jib. 生成的gitlab-ci.yml有一个 docker-push 阶段,其命令如下:

./mvnw jib:build -Djib.to.image=$IMAGE_TAG -Djib.to.auth.username=gitlab-ci-token  -Djib.to.auth.password=$CI_BUILD_TOKEN

但它失败了

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.9.11:build (default-cli) on project test-project: Obtaining project build output files failed; make sure you have compiled your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean compile jib:build"?): /builds/amatos/test-project/target/classes -> [Help 1]

由于失败了,我尝试像这样在本地运行命令:

./mvnw jib:build -Djib.to.image=registry.gitlab.com/amatos/test-project:v6.0.1 -Djib.to.auth.username=amatos -Djib.to.auth.password=password

但不是尝试连接到 Gitlab 的注册表,而是尝试连接到registry.hub.docker.com

[INFO] Retrieving registry credentials for registry.hub.docker.com...

我想知道的是:如何将其设置为连接到 Gitlab 而不是 Docker Hub?

4

2 回答 2

3

为了连接到自定义存储库,我更改-Djib.to.image-Dimage并且它有效

于 2019-05-28T20:22:14.610 回答
2

接下来是jhipster/generator-jhipster 问题 9761,其中指出:

由于这docker-push是在另一个阶段完成的,因此target/classes在前一个阶段中缺少-。
需要它jib。它应该看起来像:

maven-package:
  stage: package
  script:
    - ./mvnw verify -Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME
  artifacts:
    paths:
      - target/*.jar
      - target/classes
    expire_in: 1 day

可能由PR (merged) 9762 解决提交 50cc009,它仅在 master 中,尚未被任何标签引用。

于 2019-05-28T04:58:00.990 回答