-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-build.yml
91 lines (77 loc) · 2.4 KB
/
setup-build.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
- name: Setup Build
hosts: all
become: yes
vars:
jenkins_home: /var/lib/jenkins
jenkins_port: 8080
jenkins_plugins:
- git
- maven
tasks:
- name: Update packages
apt:
update_cache: yes
cache_valid_time: 3600
- name: Install required packages for build environment
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
- build-essential
- certbot
- python3-certbot-nginx
state: present
- name: Install OpenJDK 11
apt:
name: openjdk-11-jdk
state: present
- name: Install Jenkins dependencies
apt:
name: "{{ item }}"
state: present
with_items:
- git
- maven
- name: Add Jenkins repository key
apt_key:
url: https://pkg.jenkins.io/debian-stable/jenkins.io.key
state: present
- name: Add Jenkins repository to apt sources
apt_repository:
repo: deb [signed-by=/usr/share/keyrings/jenkins.gpg] https://pkg.jenkins.io/debian-stable binary/
state: present
filename: jenkins
- name: Install Jenkins
apt:
name: jenkins
state: present
- name: Start Jenkins service
systemd:
name: jenkins
state: started
enabled: yes
- name: Wait for Jenkins service to start
uri:
url: "http://localhost:{{ jenkins_port }}"
status_code: 200
timeout: 30
register: jenkins_up
retries: 10
delay: 10
until: jenkins_up is succeeded
- name: Install Jenkins plugins
command: "{{ jenkins_home }}/jenkins-cli.jar -s http://localhost:{{ jenkins_port }}/ install-plugin {{ item }}"
with_items: "{{ jenkins_plugins }}"
- name: Create Jenkins users
command: "{{ jenkins_home }}/jenkins-cli.jar -s http://localhost:{{ jenkins_port }}/ create-user {{ item.name }} {{ item.password }}"
with_items:
- { name: "user1", password: "password1" }
- { name: "user2", password: "password2" }
- name: Create Jenkins job
command: "{{ jenkins_home }}/jenkins-cli.jar -s http://localhost:{{ jenkins_port }}/ create-job {{ item.name }} < {{ item.config }}"
with_items:
- { name: "job1", config: "/path/to/job1/config.xml" }
- { name: "job2", config: "/path/to/job2/config.xml" }