-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathMultipleLinuxServer
169 lines (117 loc) · 3.94 KB
/
MultipleLinuxServer
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Source code for WebCalculator app is at
https://github.com/Sonal0409/JavaWebCalculator.git
Create 2 new ec2-instance and name them as QAServer & prodServer.
Go to Jenkins Master
Connect master to QAServer
Connect master to prodServer
Follow the below steps:
LINUX SLAVE
*************************
create root directory
cd /tmp
mkdir jenkisndir
give permission to the directory
sudo chmod -R 777 /tmp/jenkinsdir
Go to master
*************
Go to node
give following informtion under Launch Method
how to connect to master- select ssh
host: private ip
provide credentials
also set
Host key verfication as:
Non verifying Verification startegy
Save it.
***************************
Create a new pipeline job : QApipelineJob
Write the following pipeline as code and give Agent label as qa_Server
pipeline{
tools{
jdk 'myjava'
maven 'mymaven'
}
agent {label 'qa_Server'}
stages{
stage('checkout'){
steps{
git branch: 'qa', url: 'https://github.com/sonal04devops/JavaWebCalculator.git'
}
}
stage('Compile'){
steps{
echo 'compiling..'
sh 'mvn compile'
}
}
stage('UnitTest'){
steps{
sh 'mvn test'
}
post {
success {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Package'){
steps{
sh 'mvn package'
}
}
}
}
Save the job and Build the job
*************************************************
Create a new pipeline job : QApipelineJob
Write the following pipeline as code and give Agent label as prod_Server
pipeline{
tools{
jdk 'myjava'
maven 'mymaven'
}
agent {label 'prod_server'}
stages{
stage('checkout'){
steps{
git 'https://github.com/sonal04devops/JavaWebCalculator.git'
}
}
stage('Compile'){
steps{
echo 'compiling..'
sh 'mvn compile'
}
}
stage('UnitTest'){
steps{
sh 'mvn test'
}
post {
success {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Package'){
steps{
sh 'mvn package'
}
}
}
}
******************************************************
Otherwise you can create Jenkins files with pipeline code in respective branches (Master & QA) and then execute the Job in Jenkins.
You can also connect QA and prod jobs to get executed one after the other. This will automaticlly trigger prodServer job.
************************************
Parameters
In order to support the wide variety of use-cases Pipeline authors may have, the agent section supports a few different types of parameters. These parameters can be applied at the top-level of the pipeline block, or within each stage directive.
any
Execute the Pipeline, or stage, on any available agent. For example: agent any
none
When applied at the top-level of the pipeline block no global agent will be allocated for the entire Pipeline run and each stage section will need to contain its own agent section. For example: agent none
label
Execute the Pipeline, or stage, on an agent available in the Jenkins environment with the provided label. For example: agent { label 'my-defined-label' }
Label conditions can also be used. For example: agent { label 'my-label1 && my-label2' } or agent { label 'my-label1 || my-label2' }
node
agent { node { label 'labelName' } } behaves the same as agent { label 'labelName' }, but node allows for additional options (such as customWorkspace).