51 lines
880 B
YAML
51 lines
880 B
YAML
stages:
|
|
- build
|
|
- test
|
|
- deploy
|
|
|
|
variables:
|
|
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
|
|
|
|
cache:
|
|
paths:
|
|
- .m2/repository/
|
|
- target/
|
|
|
|
build:
|
|
stage: build
|
|
image: maven:3.6.3-jdk-11
|
|
script:
|
|
- mvn package -B
|
|
artifacts:
|
|
paths:
|
|
- target/*.jar
|
|
|
|
test:
|
|
stage: test
|
|
image: maven:3.6.3-jdk-11
|
|
script:
|
|
- mvn test -B
|
|
|
|
deploy-staging:
|
|
stage: deploy
|
|
script:
|
|
- echo "Deploying to staging server..."
|
|
- scp target/*.jar user@staging-server:/app/
|
|
environment:
|
|
name: staging
|
|
url: https://staging.example.com
|
|
when: manual
|
|
only:
|
|
- master
|
|
|
|
deploy-prod:
|
|
stage: deploy
|
|
script:
|
|
- echo "Deploying to production server..."
|
|
- scp target/*.jar user@prod-server:/app/
|
|
environment:
|
|
name: production
|
|
url: https://example.com
|
|
when: manual
|
|
only:
|
|
- tags |