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
pipeline {
agent{
label 'nodejs'
}
environment {
DOCKER_TAG = "v${env.BUILD_NUMBER}"
}
options{
// Stop the build early in case of compile or test failures
skipStagesAfterUnstable()
}
stages {
stage("Testing"){
steps{
echo "no script"
sh label: '', script: 'chmod +x changeTag.sh'
sh label: '', script: './changeTag.sh ${DOCKER_TAG}'
}
}
stage("Build Project"){
steps{
sh label: '', script: '''npm install --production
npm install react-scripts -g --silent
CI=false npm run build'''
}
}
stage("Building Frontend Image"){
steps{
sh label: '', script: '''docker build -t novisync-web-react-front-prod:v1 .
docker tag novisync-web-react-front-prod:v1 docker-registry-server:5000/novisync-web-react-front-prod:${DOCKER_TAG}'''
}
}
stage("Docker push Frontend Image"){
steps{
sh label: '', script: 'docker push docker-registry-server:5000/novisync-web-react-front-prod:${DOCKER_TAG}'
}
}
stage("Deploy Frontend to k8s"){
steps{
sh label: '', script: 'sshpass -f "/root/suresh/k8s-pro" scp -o StrictHostKeyChecking=no novisync-web-react-frontend.yml root@192.168.6.110:/root/suresh/'
sh label: '', script: 'sshpass -f "/root/suresh/k8s-pro" ssh -o StrictHostKeyChecking=no root@192.168.6.110 \'kubectl apply -f /root/suresh/novisync-web-react-frontend.yml\''
}
}
}
}
def getDockerTag(){
def tag = sh script: ' git rev-parse HEAD', returnStdout: true
return tag
}