-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojectConfig.txt
89 lines (78 loc) · 3.3 KB
/
projectConfig.txt
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
01) Create Spring boot project and expose the end points.
02) Add <finalName>docker-jenkins-integration-sample</finalName> pom.xml after plugins.
03) Create Dockerfile and add below codes.
FROM openjdk:8
EXPOSE 8080
ADD target/docker-jenkins-integration-sample.jar docker-jenkins-integration-sample.jar
ENTRYPOINT ["java","-jar","/docker-jenkins-integration-sample.jar"]
04) Create project in jenkins.
03) Create item --> Give name --> Choose Pipeline project --> Save.
04) Add Description --> Select Github project --> Add project URL
05) Check GitHub hook trigger for GITScm polling and Checked Poll SCM add valuesble (ex : * * * * *)..
06) Create pipeline to github repository.
Click pipeline syntax.
checkout: checkout from version control.
Add github repository URL.
Add branch name.
Click generate pipeline script.
Add script to jenkins file.
07) Configure the manve nin jenkins.
08) Follow this,
Windows doesn't understand the "sh" command. To enable this, add
C:\Program Files\Git\bin &
C:\Program Files\Git\usr\bin
to the System Environment variable PATH, than restart your system.
Than execute your command in jenkins, it will work.
09) Add <finalName>devops-integration</finalName> to pom.xml
10) Create docker file and add below details,
FROM openjdk:8
EXPOSE 8080
ADD target/devops-integration.jar devops-integration.jar
ENTRYPOINT ["java","-jar","/devops-integration.jar"]
11) Build the porject.
12) Push modification to github repository.
13) Add below pipeline script to jenkins pipeline.
stage('Build docker image'){
steps{
script{
sh 'docker build -t javatechie/devops-integration .'
}
}
}
14) Add docker plugin to jenkins. (Global tool configuration and manage plugins)
15) Add dockerhub pipeline script as below.
Click pipeline sytax.
Select with Credentials(Bind credentials to variable).
Give variable name.
Click Add.
Select Secret text under Kind.
Add Secret(Jenkins password).
ID (any value)
Click Generate Pipeline Script.
16) Add this stage jenkins pipeline as below
stage('Push image to Hub'){
steps{
script{
withCredentials([string(credentialsId: 'dockerhub-pwd', variable: 'dockerhubpwd')]) {
sh 'docker login -u ${dockerusername} -p ${dockerhubpwd}'
}
sh 'docker push ${dockerusername}/devops-integration'
}
}
}
17) Build project in Jenkins.
=============================== BEGIN SECOND STEP JENKINS BUILD STEP ==================================================
01) Create jenkinsfile and Add all scripts to it and push file to github.
02) Create new Jenkins project.
03) Create item --> Give name --> Choose Pipeline project --> Save.
04) Add Description --> Select Github project --> Add project URL
05) Check GitHub hook trigger for GITScm polling.
06) Checked Poll SCM add valuesble (ex : * * * * *).
07) Select pipeline script from SCM.
08) Select Git under SCM.
09) Take repository URL.
10) Check branch details.
11) Select OK and build the project.
=============================== END SECOND STEP JENKINS BUILD STEP ==================================================
18) Check dockerhub build success status.
19) Run the image and expose the end point. docker run -p 8080:8080 [repo name]