简体   繁体   English

我如何在下一阶段访问保存在 Gitlab CI/CD 工件中的文件并增加它的版本

[英]How I can access to a file saved in Gitlab CI/CD artifact in the next stages and increase it's version

I have a spring boot application and I deployed it in the first stage and now I have a jar file.我有一个 spring 启动应用程序,我在第一阶段部署了它,现在我有一个 jar 文件。 my question is how to access this jar file in the next stage and how I can run it.我的问题是如何在下一阶段访问这个 jar 文件以及如何运行它。 second question is HOW can I increase its version number?第二个问题是如何增加它的版本号? for example jar file name is spring.0.0.1.jar and I want to increase version number after every push.例如 jar 文件名是 spring.0.0.1.jar 我想在每次推送后增加版本号。 is this possible?这可能吗?

First Question:第一个问题:

You can save the jar file as an artifact and access it in the second stages jobs' script area.您可以将 jar 文件保存为工件并在第二阶段作业的脚本区域中访问它。 For example例如

FirstJob:
  stage: FirstStage
  scrip:
      - <your commands here>
  artifacs:
      paths:
        - ./artifacts/myOutput.jar

Now your "myOutput.jar" is accessible in the artifacts folder for all following jobs.现在您的“myOutput.jar”可以在以下所有作业的工件文件夹中访问。 See here: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html看这里: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html

Second Question:第二个问题:

As far as I know there is no way of handing down variables between pipelines in GitLab CI so this would not be possible if I'm right.据我所知,没有办法在 GitLab CI 中的管道之间传递变量,所以如果我是对的,这是不可能的。 Since artifacts don't get added to the repository, previous artifacts are not available to following pipelines either.由于工件不会添加到存储库中,因此之前的工件也不可用于后续管道。 Yet, if I had to come up with a solution on the spot, I'd try:然而,如果我必须当场想出一个解决方案,我会尝试:

  • Saving the version number somewhere accessible to every pipeline (cloud, repo)将版本号保存在每个管道(云、回购)都可以访问的地方
  • git push every artifact to actually add it to the repository, then check file name and increment version number git 推送每个工件以将其实际添加到存储库中,然后检查文件名并增加版本号
  • using the GitLab CI release option.使用 GitLab CI 发布选项。 The CI can create a release object for you, maybe this could help as well. CI 可以为您创建一个版本 object,也许这也有帮助。 See here: https://docs.gitlab.com/ee/ci/yaml/README.html#release看这里: https://docs.gitlab.com/ee/ci/yaml/README.html#release

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GitLab CI CD runner 未加载配置文件的属性文件 - GitLab CI CD runner not loading properties file for profile GitLab CI/CD Maven SpringBoot上传*jar错误:没有这样的文件或目录 - GitLab CI/CD Maven SpringBoot upload *jar error: No such file or directory Gitlab CI/CD 管道中 SpringBoot 服务的健康检查 - Healthcheck of SpringBoot service in Gitlab CI/CD pipeline Spring 启动和 mongo db gitlab CI/CD - Spring boot and mongo db gitlab CI/CD Gitlab CI/CD 跨项目工件不使用“需要”下载 - Gitlab CI/CD cross project artifacts not downloading using "needs" 我如何在gitlab-ci工作中添加计时器以使其在gitlab-ci.yml中停止1分钟 - How do I add a timer to my gitlab-ci job to make it stop within 1 minute in gitlab-ci.yml 如何增加 Vaadin 中的最大文件上传 - Spring Boot - How can I increase maximum file upload in Vaadin - Spring Boot Gradle bootBuildImage 使用 docker:dind 服务在 GitLab CI/CD 中失败并出现“未找到摘要” - Gradle bootBuildImage fails with 'No digest found' in GitLab CI/CD using docker:dind service 如何使用 GitLab 的 API 创建 Spring Boot rest api 以从 GitLab 中提取特定的存储库分支? - How I can create a Spring Boot rest api to pull the specific repository branches from GitLab by using GitLab's API? 用于托管 jar 文件的 Azure Springboot (Java) 管道 CI/CD - Azure Springboot (Java) pipeline CI/CD to host jar file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM