-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
43 lines (41 loc) · 1.04 KB
/
Jenkinsfile
File metadata and controls
43 lines (41 loc) · 1.04 KB
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
pipeline {
agent any
tools { go '1.19' }
stages {
stage('Checkout SCM') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: 'main']],
userRemoteConfigs: [[
url: 'https://github.com/cloudboundboris/web_app.git',
credentialsId: '',
]]
])
}
}
stage('Build') {
steps {
echo 'Building application...'
sh 'go build ./web_app.go'
}
}
stage('Test') {
steps {
echo 'Testing application...'
sh './web_app &'
sh '''response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:80) &&
echo Response is: $response &&
[ "$response" = "200" ] && exit 0 || exit 1'''
}
}
stage('Deploy') {
steps {
echo 'Deploying application...'
sshagent(credentials: ['creds_srv']) {
sh 'ssh -o StrictHostKeyChecking=no root@192.168.4.238 "cd /web_app && git pull && go build ./web_app.go && ./web_app &"'
}
}
}
}
}