-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinfile.cdk.ci
71 lines (68 loc) · 2.2 KB
/
Jenkinfile.cdk.ci
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
#!/usr/bin/env groovy
//
// CDK CI Pipeline
//
// Repository | https://github.com/DevOpsSampleOrg/jenkins-pipeline/tree/master/Jenkinfile.cdk.ci
// Environment | AWS
// AWS Key | Not required
// Build Tool | node-12-13-1, gradle-6-9
// Parameters |----------------------------------------------------------------------|
// | 1 | REPO_URL | Mandatory | GitHub/CodeCommit URL |
// | 2 | BRANCH | Mandatory | develop, feature_xxx, master |
// | 3 | PR_ID | Optional | Pull Request ID |
// | 4 | STAGE | Mandatory | dev, stg, prd |
def repoUrl = params.REPO_URL
pipeline {
tools {
nodejs 'node-16-16-0'
}
// agent {
// node {
// label slaveNode
// }
// }
agent any
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr:'20'))
}
stages {
stage('Cleanup Workspace') {
steps {
cleanWs()
}
}
stage('Checkout') {
steps {
git url: repoUrl, branch: params.BRANCH, credentialsId: env.GIT_CREDENTIALS_ID
}
}
stage("npm install") {
steps {
sh 'npm install'
}
}
stage("Build") {
steps {
sh 'npm run build'
}
}
stage("SonarQube Quality Gate") {
steps {
withSonarQubeEnv('SonarQube') {
script {
def sonarCmd = 'gradle sonar'
if (params.PR_ID != '') {
sonarCmd += ' -Dsonar.pullrequest.key='+ params.PR_ID
sonarCmd += ' -Dsonar.pullrequest.branch='+ params.BRANCH
sonarCmd += ' -Dsonar.pullrequest.base='+ params.BASE_BRANCH
sonarCmd += ' -Dsonar.pullrequest.github.repository='+ repoUrl
}
sh sonarCmd
}
}
waitForQualityGate abortPipeline: true
}
}
}
}