forked from semaphoreci-demos/semaphore-demo-java-spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
semaphore.yml
107 lines (94 loc) · 3.38 KB
/
semaphore.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Use the latest stable version of Semaphore 2.0 YML syntax:
version: v1.0
# Name of your pipeline. In this example we connect two pipelines with
# a promotion, so it helps to differentiate what's the job of each.
name: Java Spring example CI pipeline on Semaphore
# An agent defines the environment in which your code runs.
# It is a combination of one of available machine types and operating
# system images. See:
# https://docs.semaphoreci.com/article/20-machine-types
# https://docs.semaphoreci.com/article/32-ubuntu-1804-image
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
# Blocks are the heart of a pipeline and are executed sequentially.
# Each block has a task that defines one or more jobs. Jobs define the
# commands to execute.
# See https://docs.semaphoreci.com/article/62-concepts
blocks:
- name: "Build"
task:
# Set environment variables that your project requires.
# See https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
env_vars:
- name: MAVEN_OPTS
value: "-Dmaven.repo.local=.m2"
jobs:
- name: Build
commands:
# Checkout code from Git repository. This step is mandatory if the
# job is to work with your code.
- checkout
# Restore dependencies from cache, command won't fail if it's
# missing.
# More on caching: https://docs.semaphoreci.com/article/54-toolbox-reference#cache
- cache restore
- mvn -q package jmeter:configure -Dmaven.test.skip=true
# Store the latest version of dependencies in cache,
# to be used in next blocks and future workflows:
- cache store
- name: "Test"
task:
env_vars:
- name: MAVEN_OPTS
value: "-Dmaven.repo.local=.m2"
# This block runs two jobs in parallel and they both share common
# setup steps. We can group them in a prologue.
# See https://docs.semaphoreci.com/article/50-pipeline-yaml#prologue
prologue:
commands:
- checkout
- cache restore
- mvn -q test-compile -Dmaven.test.skip=true
jobs:
- name: Unit tests
commands:
- mvn test
- name: Integration tests
commands:
- mvn test -Pintegration-testing
- name: "Performance tests"
task:
env_vars:
- name: MAVEN_OPTS
value: "-Dmaven.repo.local=.m2"
prologue:
commands:
- checkout
- cache restore
jobs:
- name: Benchmark
commands:
- java -version
# Run application in detached mode:
- java -jar target/spring-pipeline-demo.jar > /dev/null &
# Wait for the spring boot application to boot
- sleep 20
- mvn -q jmeter:jmeter
- mvn jmeter:results
# If all tests pass, we move on to build a Docker image.
# This is a job for a separate pipeline which we link with a promotion.
#
# What happens outside semaphore.yml will not appear in GitHub pull
# request status report.
#
# In this example we run docker build automatically on every branch.
# You may want to limit it by branch name, or trigger it manually.
# For more on such options, see:
# https://docs.semaphoreci.com/article/50-pipeline-yaml#promotions
promotions:
- name: Dockerize
pipeline_file: docker-build.yml
auto_promote_on:
- result: passed