-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile
58 lines (53 loc) · 2.02 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
node {
// hold short version of commit sha for this checkout
def shortSha = ''
def PATH = '/Applications/Docker.app/Contents/Resources/bin/docker'
/**
* checks out master branch from Github
*/
stage('Checkout') {
def scm = git branch: 'master', url: 'git@github.com:mrmodise/senepe.git'
shortSha = scm.GIT_COMMIT.take(8)
}
/*
* builds the site using the prod target and environment
* the minified site will be in the dist folder
*/
stage('Build Artificats') {
parallel(
"Front-End": {
nodejs('nodejs') { // adds the node environment to PATH
sh 'npm install'
sh 'npm run build'
}
},
"Back-End": {
withMaven(maven: 'maven',
mavenLocalRepo: '.repository') {
sh 'cd backend && mvn package'
}
}
)
}
stage('Build and Push Docker Image') {
parallel(
"Front-End Image": {
sh "${PATH} build -t backend:latest ."
sh "${PATH} tag backend:latest mrmodise/backend:latest"
withCredentials([usernamePassword(credentialsId: '71fb80cb-cb5f-4313-82d2-17e18f4aa3a7', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
sh "${PATH} login --username=mrmodise --password-stdin ${PASSWD} && ${PATH} push mrmodise/backend:latest"
}
},
"Back-End Image": {
sh "cd backend && ${PATH} build -t backend:latest ."
sh "${PATH} tag backend:latest mrmodise/backend:latest"
withCredentials([usernamePassword(credentialsId: '71fb80cb-cb5f-4313-82d2-17e18f4aa3a7', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
sh "${PATH} login --username=mrmodise --password-stdin && ${PATH} push mrmodise/backend:latest"
}
}
)
}
/**
// updates deployment with latest dev Docker image
stage('deploy to dev') {withCredentials([file(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {sh "kubectl set image deploy mydiary-site-deploy mydiary-site=clf112358/mydiary-angular:dev-${shortSha} --record=true"}}*/
}