简体   繁体   中英

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. my question is how to access this jar file in the next stage and how I can run it. 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. is this possible?

First Question:

You can save the jar file as an artifact and access it in the second stages jobs' script area. 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. See here: 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. 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
  • using the GitLab CI release option. The CI can create a release object for you, maybe this could help as well. See here: https://docs.gitlab.com/ee/ci/yaml/README.html#release

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM