-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
76 lines (66 loc) · 3.04 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
version: 2.1 # use CircleCI 2.0
orbs:
slack: circleci/slack@4.10.1
aliases:
- &exclude-deploy
branches:
ignore: /deploy-.*/
- &include-deploy-prd
branches:
only: /deploy-prd/
- &save_surefire
# https://circleci.com/docs/2.0/collect-test-data/#maven-surefire-plugin-for-java-junit-results
name: Save JUnit results
# https://unix.stackexchange.com/questions/83593/copy-specific-file-type-keeping-the-folder-structure
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp --parents {} ~/test-results/junit/ \;
find . -type f -regex ".*/target/surefire-reports/.*txt" -exec cp --parents {} ~/test-results/junit/ \;
when: always
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/circleci-demo-java-spring # directory where steps will run
docker: # run the steps with Docker
- image: circleci/openjdk:11-jdk
steps: # a collection of executable commands
- checkout # check out source code to working directory
- restore_cache: # restore the saved cache after the first run or if `pom.xml` has changed
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run: mvn package -DskipTests
- save_cache: # saves the project dependencies
paths:
- ~/.m2
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run: mvn package # run the actual tests
# This will enable quickly seeing failed tests in CircleCI GUI
# https://circleci.com/docs/2.0/collect-test-data/
- run: *save_surefire
- store_test_results:
path: ~/test-results/junit
deploy-lambda: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/circleci-demo-java-spring # directory where steps will run
docker: # run the steps with Docker
- image: circleci/openjdk:11-jdk
steps: # a collection of executable commands
- checkout # check out source code to working directory
- restore_cache: # restore the saved cache after the first run or if `pom.xml` has changed
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
key: circleci-demo-java-spring-{{ checksum "pom.xml" }}
- run: mvn clean install -pl :lambda -am -DskipTests -PskipStyle
- run: mvn lambda:deploy-lambda -pl :lambda
workflows:
build_and_test:
jobs:
- build:
filters: *exclude-deploy
build_and_deploy:
jobs:
# We might require a manual click in CircleCI UI: https://circleci.com/docs/2.0/workflows/#holding-a-workflow-for-a-manual-approval
- build:
context: slack-secrets
filters: *include-deploy-prd
- deploy-lambda:
# https://ideas.circleci.com/cloud-feature-requests/p/multiple-contexts-in-a-workflow
context: aws-cleanthat
filters: *include-deploy-prd