-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
61 lines (53 loc) · 1.8 KB
/
Jenkinsfile
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
script {
System.setProperty("org.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL", "3800");
}
pipeline{
agent any
tools {
gradle 'gradle 8.8'
}
stages{
stage('Ready'){
steps{
sh "echo 'Ready'"
git branch: 'dev',
credentialsId: 'detour_github',
url: 'https://github.com/BE-Friend-Develop-Team/detour'
}
}
stage('Test'){
steps{
sh "echo 'Test'"
sh 'chmod +x /var/jenkins_home/workspace/detour_dev/gradlew'
sh '/var/jenkins_home/workspace/detour_dev/gradlew clean test'
}
}
stage('Build'){
steps{
sh "echo 'Build Jar'"
sh '/var/jenkins_home/workspace/detour_dev/gradlew bootJar'
}
}
stage('Deploy'){
steps{
script{
withCredentials([sshUserPrivateKey(credentialsId: "pem-key", keyFileVariable: 'my_private_key_file')]) {
def remote = [:]
remote.name = "pem-key"
remote.host = "${env.DEV_BACK_IP}"
remote.user = "ubuntu"
remote.allowAnyHosts = true
remote.identityFile = my_private_key_file
sh "echo 'Deploy AWS'"
dir('detour/build/libs'){
sh "scp -o StrictHostKeyChecking=no -i ${my_private_key_file} /var/jenkins_home/workspace/detour_dev/build/libs/*.jar ubuntu@${env.DEV_BACK_IP}:/home/ubuntu/detour"
sh "scp -o StrictHostKeyChecking=no -i ${my_private_key_file} /var/jenkins_home/workspace/detour_dev/deploy.sh ec2-user@${env.DEV_BACK_IP}:/home/ubuntu/detour"
}
sh "ssh -o StrictHostKeyChecking=no -i ${my_private_key_file} ubuntu@${env.DEV_BACK_IP} 'cd /home/ubuntu/detour && ./deploy.sh'"
sh "echo 'Spring Boot Running'"
}
}
}
}
}
}