-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
64 lines (52 loc) · 1.9 KB
/
Makefile
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
include Makefile.settings
.PHONY: init build clean publish log jenkins slave
# Jenkins settings
export DOCKER_GID ?= 0
export JENKINS_USERNAME ?= admin
export JENKINS_PASSWORD ?= password
export JENKINS_SLAVE_VERSION ?= 3.9
export JENKINS_SLAVE_LABELS ?= DOCKER
# AWS settings
# The role to assume to inject temporary credentials into your Jenkins container
AWS_ROLE ?= `aws configure get role_arn`
# KMS encrypted password - the temporary credentials must possess kms:decrypt permissions for the key used to encrypt the credentials
export KMS_JENKINS_PASSWORD ?=
init:
${INFO} "Creating volumes..."
@ docker volume create --name=jenkins_home
build:
${INFO} "Building image..."
@ docker-compose build --pull
${INFO} "Build complete"
jenkins: init
@ $(if $(and $(AWS_PROFILE),$(KMS_JENKINS_PASSWORD)),$(call assume_role,$(AWS_ROLE)),)
${INFO} "Starting Jenkins..."
${INFO} "This may take some time..."
@ docker-compose up -d jenkins
@ $(call check_service_health,$(RELEASE_ARGS),jenkins)
${INFO} "Jenkins is running at http://$(DOCKER_HOST_IP):$(call get_port_mapping,jenkins,8080)..."
publish:
${INFO} "Publishing images..."
@ docker-compose push
${INFO} "Publish complete"
slave:
${INFO} "Checking Jenkins is healthy..."
@ $(if $(and $(AWS_PROFILE),$(KMS_JENKINS_PASSWORD)),$(call assume_role,$(AWS_ROLE)),)
@ $(call check_service_health,$(RELEASE_ARGS),jenkins)
${INFO} "Starting $(SLAVE_COUNT) slave(s)..."
@ docker-compose up -d --scale jenkins-slave=$(SLAVE_COUNT)
${INFO} "$(SLAVE_COUNT) slave(s) running"
clean:
${INFO} "Stopping services..."
@ docker-compose down -v || true
${INFO} "Services stopped"
destroy: clean
${INFO} "Deleting jenkins home volume..."
@ docker volume rm -f jenkins_home
${INFO} "Deletion complete"
log:
${INFO} "Streaming Jenkins logs - press CTRL+C to exit..."
@ docker-compose logs -f jenkins
# IMPORTANT - ensures arguments are not interpreted as make targets
%:
@: