-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
98 lines (91 loc) · 2.84 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
pipeline {
agent any
environment {
GOOGLE_PROJECT_ID = 'dsc-fptu-hcmc-orientation'
}
options {
// Keep the 10 most recent builds
buildDiscarder(logRotator(numToKeepStr:'10'))
}
stages {
stage('Install dependencies') {
steps {
script {
if (fileExists('dist'))
sh 'rm -rf dist'
if (fileExists('node_modules'))
sh 'rm -rf node_modules'
if (fileExists('rm package-lock.json'))
sh 'rm package-lock.json'
}
sh '''
echo "PATH = ${PATH}"
node --version
npm --version
npm cache clean --force
npm install
echo "Install dependencies successfully!"
'''
}
}
// stage('Test Code Coverage') {
// steps {
// sh './node_modules/.bin/ng test --no-watch --code-coverage'
// // create the `reports` directory if not exist
// publishHTML(
// target : [
// allowMissing: false,
// alwaysLinkToLastBuild: false,
// keepAll: true,
// reportDir: './coverage/angular-boilerplate/',
// reportFiles: 'index.html',
// reportName: 'RCov Report',
// reportTitles: 'RCov Report'
// ]
// )
// }
// }
stage('Bundle Angular application') {
steps {
sh '''
echo "BUILD NUMBER = $BUILD_NUMBER"
./node_modules/.bin/ng build --aot --prod
echo ""
'''
}
post {
success {
// Archive the built artifacts
archiveArtifacts(
artifacts: 'dist/**/*.*',
allowEmptyArchive: false
)
// emailext (
// subject: "BUILD SUCCESS: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
// body: """<p>BUILD SUCCESS: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
// <p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
// recipientProviders: [[$class: 'DevelopersRecipientProvider']]
// )
}
}
}
stage('Deploy to production') {
steps {
withCredentials([file(credentialsId: 'google-application-credentials-secret-file', variable: 'GOOGLE_APPLICATION_CREDENTIALS')]) {
input message: 'Deploy to production? (Click "Proceed" to continue)'
sh '''
gcloud --version
echo "GCP credentails: $GOOGLE_APPLICATION_CREDENTIALS"
gcloud config set project $GOOGLE_PROJECT_ID
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
gcloud config list
cp app.yaml dist/app.yaml
cd dist
gcloud app deploy --version=v01
echo "Deployed to Google Compute Engine"
'''
}
}
}
}
}