-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile
31 lines (28 loc) · 878 Bytes
/
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
pipeline {
agent any
environment {
EC2_IP = '54.75.33.241'
}
stages {
stage ('fetch code') {
steps {
script {
echo "Pull source code from Git"
git branch: 'jenkins', url: 'https://github.com/seunayolu/jenkins_deploy_ec2.git'
}
}
}
stage ('deploy to EC2') {
steps {
script {
echo "deploying to shell-script to ec2"
def shellCmd = "bash ./websetup.sh"
sshagent (['ec2']) {
sh "scp -o StrictHostKeyChecking=no websetup.sh ubuntu@${EC2_IP}:/home/ubuntu"
sh "ssh -o StrictHostKeyChecking=no ubuntu@${EC2_IP} ${shellCmd}"
}
}
}
}
}
}