-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
32 lines (26 loc) · 1004 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
32
node {
stage('Clone repository') {
/* Let's make sure we have the repository cloned to our workspace */
checkout scm
}
stage('Sonarqube - Testing'){
}
stage('Build Image') {
docker.build "$YOUR_USER/${JOB_NAME}:latest"
}
stage('Push Docker Image'){
withCredentials([string(credentialsId: 'DockerHubPassword', variable: 'dockerHubPwd')]) {
sh "docker login -u $YOUR_USER -p ${dockerHubPwd}"
}
sh "docker push $YOUR_USER/${JOB_NAME}:latest"
}
stage('Run Container on Server'){
def dockerRun = 'docker-compose --file aspnetcore-metrics-app/docker-compose.yaml up -d --force-recreate net-application'
sshagent(['dev-server']) {
sh "ssh -o StrictHostKeyChecking=no $REMOTE_USER@$IP_ADDRES_SERVER ${dockerRun}"
}
}
stage ('Email Notification'){
mail bcc: '', body: 'PIPELINE SUCCESS!', cc: '', from: '', replyTo: '', subject: 'Jenkins - Build', to: 'YOUR_EMAIL_TO_NOTIFICATION'
}
}