forked from dag-gitfocus/GitFocusAngular_kube
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
88 lines (88 loc) · 2.92 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
pipeline {
environment {
registry = "priya2802/gitfocus_service_kube"
registryCredential = 'GITFocus-DockerHub'
dockerImage = ''
}
agent any
stages {
stage('Initialize'){
steps {
nodejs('DAGNodeJS'){
sh 'npm install'
sh 'cp index.d.ts ./node_modules/@types/chart.js'
}
}
}
stage('Build') {
steps {
nodejs('DAGNodeJS'){
sh 'npm run-script build'
}
}
}
stage ("Code Analysis") {
steps {
script{
def scannerHome = tool 'DAGSonarScanner'
}
withSonarQubeEnv('SonarQube') {
sh 'pwd'
sh 'cp sonar-scanner.properties /var/jenkins_home/sonar-scanner-4.4.0.2170-linux/conf'
sh '/var/jenkins_home/sonar-scanner-4.4.0.2170-linux/bin/sonar-scanner'
}
}
}
stage("Quality Check"){
steps{
script{
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
}
stage('Building Image') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
//dockerImage = docker.build registry + ":1.1"
}
}
}
stage('Clean Up'){
steps {
sh 'rm -r src output e2e'
sh 'rm -f browserslist tsconfig.app.json README.md tsconfig.json angular.json tsconfig.spec.json karma.conf.js tslint.json index.d.ts'
}
}
stage('Approval') {
steps {
script {
timeout (time: 2, unit: 'MINUTES') {
def deploymentDelay = input id: 'Deploy', message: 'Push Image to DockerHub?', submitter: 'admin', parameters: [choice(choices: ['0', '1', '2', '3'], description: 'Hours to delay deployment?', name: 'deploymentDelay')]
sleep time: deploymentDelay.toInteger(), unit: 'HOURS'
}
}
}
}
stage('Push to DockerHub') {
steps{
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push()
}
}
}
}
}
post {
always {
cleanWs()
emailext body:'''${DEFAULT_CONTENT}''',
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
subject:''' ${DEFAULT_SUBJECT}'''
}
}
}