[英]How to make GitLab CI Release a Spring Boot JAR using gradle?
I have a Spring Boot project that builds using a bootJar task in gradle. 我有一个使用Gradle中的bootJar任务构建的Spring Boot项目。 It produces a runnable ____-1.0-SNAPSHOT.jar file.
它会生成一个可运行的____- 1.0-SNAPSHOT.jar文件。 Now, I want to leverage GitLab CI to build the JAR and make releases.
现在,我想利用GitLab CI来构建JAR并发布版本。
There didn't seem to be an obvious way to do the builds. 似乎没有明显的方法可以进行构建。 I started looking at the researchgate gradle plugin .
我开始研究researchgate gradle插件 。 It seems promising but has a lot of assumptions.
看起来很有希望,但有很多假设。
What is the best way to get the release JARs out of GitLab CI? 从GitLab CI中获取发布JAR的最佳方法是什么?
There is couple of ways of getting released artifacts from gitlab ci pipeline. 有几种方法可以从gitlab ci管道中获取发布的工件。
Here is the sample .gitlab-ci.yml which uses gitlab job artifacts functionality (assume gradle wrapper is used) 这是使用gitlab作业工件功能的示例.gitlab-ci.yml(假定使用gradle包装器)
image: java:8-jdk
cache:
paths:
- .gradle/wrapper
- .gradle/caches
build:
stage: build
script:
- ./gradlew assemble
# define path to collect artifacts
artifacts:
paths:
- build/libs/*.jar
expire_in: 1 week
only:
- master
Ruwanka provided a great answer, however I believe it is now a bit outdated. Ruwanka提供了一个很好的答案,但是我认为现在有点过时了。 GitLab.com (and self-hosted) now supports hosted maven repositories as a native feature of their Premium tiers.
GitLab.com(和自托管)现在支持托管maven存储库,作为其Premium层的本机功能。
More information regarding how to deploy a java application (JAR, etc.) for private or public consumption can be found here: 在此处可以找到有关如何为私人或公共消费部署Java应用程序(JAR等)的更多信息:
https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#gitlab-maven-repository-premium https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#gitlab-maven-repository-premium
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.