-
Notifications
You must be signed in to change notification settings - Fork 59
/
jenkins
68 lines (46 loc) · 2.14 KB
/
jenkins
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
Links:
https://www.jenkins.io/doc/book/installing/linux/
root@ip-172-31-10-22:~# history
1 apt update -y
2 sudo apt install openjdk-11-jre -y
3 java -version
4 curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
5 echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
6 apt update -y
7 apt-get update -y
8 apt-get install jenkins -y
9 lsof -i -P -n | grep LISTEN
10 cat /var/lib/jenkins/secrets/initialAdminPassword
11 history
Slave nodes
Manage Jenkins --> Nodes and Clouds --> Add New Node
--> home directory --> /home/ubuntu
Manage Jenkins --> Security --> Agents -- select random
open ports in Security Group --> ALL TCP
To connect jenkins with slave nodes, execute following commands:
curl -sO http://jenkins-server-ip:port/jnlpJars/agent.jar
java -jar agent.jar -jnlpUrl http://jenkins-server-ip:port/computer/TestServer/jenkins-agent.jnlp -secret 3c0d4849ef99ba989f54e942d9942b21b9a6085aa8d9ed708a270b246f5092c6 -workDir "/home/ubuntu"
Install Docker on slave node and deploy a container --> docker run -itd -p 82:80 httpd
Dockerfile
https://github.com/raushan8586/pipeline1.git
Docker-Job
sudo docker rm -f $(sudo docker ps -a -q)
sudo docker build /home/ubuntu/workspace/job2/ -t httpd1
sudo docker run -itd -p 82:80 httpd1
If you need to run commands/scripts as root user-->
visudo
jenkins ALL=(ALL) NOPASSWD: ALL --> Add this line to sudoers
service jenkins status
service jenkins stop
service jenkins start
Jenkinsfile
https://www.jenkins.io/doc/book/pipeline/
https://www.jenkins.io/doc/book/pipeline/syntax/
https://www.jenkins.io/doc/book/pipeline/docker/
https://github.com/raushan8586/MyLab
More Jenkinsfile
-----------------
https://github.com/eldada/jenkins-pipeline-kubernetes
https://github.com/hakdogan/jenkins-pipeline/blob/master/Jenkinsfile
https://gist.github.com/gazoakley/87dcc16d28fd05acda4ba0a4be5ac387
https://github.com/jenkins-docs/simple-java-maven-app/blob/master/jenkins/Jenkinsfile