forked from dag-gitfocus/GitFocusAngular_kube
-
Notifications
You must be signed in to change notification settings - Fork 1
/
GitFocusAngularDeployment
117 lines (114 loc) · 4.76 KB
/
GitFocusAngularDeployment
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
pipeline {
environment {
registry = "792429589635.dkr.ecr.ap-south-1.amazonaws.com/gitfocus"
registryCredential = 'AWS_Cred'
dockerImage = ''
}
agent any
tools {
maven 'maven 3.6.3'
}
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 'DAGSonarQubeScanner'
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'
sh "cp sonar-scanner.properties ${scannerHome}/conf"
sh "${scannerHome}/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 {
sh 'pwd'
sh 'ls -l'
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('Push to ECR') {
steps{
script {
docker.withRegistry( 'http://792429589635.dkr.ecr.ap-south-1.amazonaws.com/gitfocus', 'ecr:ap-south-1:AWS_Cred' ) {
dockerImage.push()+ ':${BUILD_NUMBER}'
}
}
}
}
/* stage('Approval') {
steps {
script {
timeout (time: 10, 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('Deploy in Cluster') {
steps {
script {
withCredentials([sshUserPrivateKey(credentialsId: 'AWS_Gitfocus_Key', keyFileVariable: 'keyFile', passphraseVariable: '', usernameVariable: 'ubuntu')]) {
echo keyFile
print 'keyFile=' + keyFile
print 'keyFileContent=' + readFile(keyFile)
def remote = [name: 'GITFocusCICD', host: 'ec2-65-0-131-53.ap-south-1.compute.amazonaws.com', identityFile : keyFile, user: 'ubuntu', allowAnyHosts: true]
sh 'ls -l'
sshCommand remote: remote, command: "ls -l"
sshPut remote: remote, from: './AngularDeployment.yaml', into: './gitfocusapp'
sshPut remote: remote, from: './AngularLoadBalService.yaml', into: './gitfocusapp'
sshCommand remote: remote, command: "kubectl create -f ./gitfocusapp/AngularDeployment.yaml"
//sshCommand remote: remote, command: "kubectl create -f ./gitfocusapp/AngularLoadBalService.yaml"
sshCommand remote: remote, command: "kubectl set image deployment/gitui-deployment gitui-container=priya2802/gitfocus_service_kube:$BUILD_NUMBER"
}
}
}
}*/
}
post {
always {
cleanWs()
/*emailext body:'''${DEFAULT_CONTENT}''',
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
subject:''' ${DEFAULT_SUBJECT}'''*/
}
}
}