I currently have these gitlab stages outlined below in my .gitlab-ci.yml
I created it this way to visualize in gitlab each maven stage in the pipeline. however, because maven automatically executes preceding stages in the build life cycle it means i’m wasting a lot of time and cpu in the test and deploy gitlab stages because these re-execute their preceding maven stages.
Is it possible for gitlab and maven to play nicely so I can visualize each maven stage visually in gitlab without maven re-executing previous stages in the build lifecycle and instead use the artifacts from the previous job in the pipeline?
Or, do I need to just consolidate the three stages into a single, ‘mvn clean deploy -U’ stage?
stages:
- build
- test
- deploy
build:
tags:
- core
variables:
GIT_STRATEGY: fetch
stage: build
script: - echo ‘Building’
- mvn $MAVEN_CLI_OPTS -T 4 clean install -U
test:
tags:
- core
stage: test
script: - echo ‘Testing’
- mvn $MAVEN_CLI_OPTS test
deploy:
tags:
- core
artifacts:
expire_in: 1 week
when: always
paths:- target/*
variables:
GIT_STRATEGY: none
stage: deploy
script:
- target/*
- echo ‘Deploying to Nexus’
- ‘mvn $MAVEN_CLI_OPTS deploy -U’