Fred
Fred

Reputation: 414

How to save only the war file in artifacts between 'mvn deploy' (to nexus) and 'mvn cargo:deploy'

My .gitlab-ci.yml file has the following cache and stages defined

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .m2/repository/
    - target/
  policy: pull-push


stages:
  - build
  - nexus
  - deploy-test
  - deploy-prod

The 'build' includes....

script:
    - 'mvn $MAVEN_CLI_OPTS clean -U compile -T 6 process-classes -DjspcGoal=compile'
  artifacts:
    expire_in: 3 days
    paths:

and nexus as...

  script:
   - 'mvn $MAVEN_CLI_OPTS -DskipTests deploy'
  artifacts:
    expire_in: 3 days
    paths:
    - target/*
  dependencies:
    - build
  needs:
    - job: build
      artifacts: true

and deploy-test stage as...

script:
  - 'mvn $MAVEN_CLI_OPTS -DskipTests cargo:redeploy -Dcontext=${contextAndVersion} -Dtarget=staging.www
  artifacts:
    expire_in: 3 days
    paths:
    - target/*
  dependencies:
    - nexus
  needs:
    - job: nexus
      artifacts: true

...and a similar stage for deploy-prod (for cargo-deploy to production servers)

I'm seeing three issues which seem to be very inefficient and unnecessary:

  1. There is a lot of overhead between the stages where gitlab is retrieving the whole cache from Minio even though I've specific the project to always use the same gitlab-runner.
  2. The artifacts for the deploy-test stage include ALL of the code, classes and war file. I would expect this to only have the war file.

I'd like the deploy-test and deploy-prod stages to just retrieve the WAR file, either from the minio cache or Nexus rather than needing to download and unzip the whole target folder. I'm hoping I'm missing something simple in the Gitlab yml file (?)

Upvotes: 2

Views: 472

Answers (0)

Related Questions