-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
94 lines (82 loc) · 2.63 KB
/
Taskfile.yaml
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
version: 3
dotenv:
- .env
vars:
DOCKER_FILE: modules/jenkins/docker/Dockerfile
JCASC_CONFIG_PATH: modules/jenkins/jcasc/
PLUGINS_FILE: modules/jenkins/plugins/plugins.txt
REPOSITORY:
sh: grep 'LABEL repository=' {{.DOCKER_FILE}} | cut -d '"' -f 2
VERSION:
sh: grep 'LABEL version=' {{.DOCKER_FILE}} | cut -d '"' -f 2
tasks:
docker:build:
desc: Build Jenkins image
cmd: |
docker build \
--build-arg AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
--build-arg AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
--build-arg JCASC_CONFIG_PATH="{{.JCASC_CONFIG_PATH}}" \
--build-arg JENKINS_ADMIN_DESC="$JENKINS_ADMIN_DESC" \
--build-arg JENKINS_ADMIN_EMAIL="$JENKINS_ADMIN_EMAIL" \
--build-arg JENKINS_ADMIN_NAME="$JENKINS_ADMIN_NAME" \
--build-arg JENKINS_ADMIN_PASS="$JENKINS_ADMIN_PASS" \
--build-arg JENKINS_ADMIN_USER="$JENKINS_ADMIN_USER" \
--build-arg GITHUB_ACCESS_TOKEN="$GITHUB_ACCESS_TOKEN" \
--build-arg GITHUB_USER="$GITHUB_USER" \
--build-arg PLUGINS_FILE="{{.PLUGINS_FILE}}" \
--file {{.DOCKER_FILE}} \
--tag {{.REPOSITORY}}/jenkins:{{.VERSION}} \
--no-cache \
.
silent: true
docker:run:
desc: Run local Jenkins container
cmd: |
docker run \
--detach \
--name jenkins \
--publish 8080:8080 \
--volume /var/run/docker.sock:/var/run/docker.sock \
--user root \
{{.REPOSITORY}}/jenkins:{{.VERSION}}
silent: true
docker:tag:
desc: "Tag Jenkins image"
cmd: docker tag {{.REPOSITORY}}/jenkins:{{.VERSION}} {{.REPOSITORY}}/jenkins:latest
silent: true
docker:push:
desc: Push Jenkins image to DockerHub
cmds:
- docker push {{.REPOSITORY}}/jenkins:{{.VERSION}}
- docker push {{.REPOSITORY}}/jenkins:latest
silent: true
tf:init:
desc: Initialize Terraform working directory
cmd: terraform init -upgrade
silent: true
tf:validate:
desc: Validate the Terraform configuration
cmd: terraform validate
silent: true
tf:fmt:
desc: Format Terraform configuration files
cmd: terraform fmt -recursive
silent: true
tf:plan:
desc: Create execution plan from the Terraform configuration
cmd: terraform plan -out=plan.out
silent: true
tf:apply:
desc: Apply Terraform configuration
cmds:
- defer: |
rm plan.out
rm -f modules/jenkins/jcasc/clouds.ecs.yaml
- task: tf:plan
- terraform apply plan.out
silent: true
tf:destroy:
desc: Destroy Terraform configuration
cmd: terraform destroy -auto-approve
silent: true