将JHipster 6.0.1推送到Gitlab存储库

时间:2019-05-28 01:55:50

标签: docker gitlab jhipster jib

一切准备就绪后,我意识到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?

2 个答案:

答案 0 :(得分:2)

其后是jhipster/generator-jhipster issue 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) 9762commit 50cc009寻址,该地址仅在主服务器中,尚未被任何标签引用。

答案 1 :(得分:1)

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