-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
76 lines (76 loc) · 2.61 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
pipeline {
agent any
environment {
GIT_REPO = 'bookstore-front'
GIT_CREDENTIAL_ID = '7c21addc-0cbf-4f2e-9bd8-eced479c56c6'
SONARQUBE_URL = 'http://172.24.100.52:8082/sonar-isis2603'
SONAR_TOKEN = credentials('sonar-login')
}
stages {
stage('Checkout') {
steps {
scmSkip(deleteBuild: true, skipPattern:'.*\\[ci-skip\\].*')
git branch: 'main',
credentialsId: env.GIT_CREDENTIAL_ID,
url: 'https://github.com/Uniandes-isis2603/' + env.GIT_REPO
}
}
stage('Statistical analysis') {
steps {
withCredentials([usernamePassword(credentialsId: env.GIT_CREDENTIAL_ID, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh 'mkdir -p code-analyzer-report'
sh """ curl --request POST --url https://code-analyzer.virtual.uniandes.edu.co/analyze --header "Content-Type: application/json" --data '{"repo_url":"[email protected]:Uniandes-isis2603/bookstore-front.git", "access_token": "${GIT_PASSWORD}" }' > code-analyzer-report/index.html """
}
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'code-analyzer-report',
reportFiles: 'index.html',
reportName: "GitInspector"
])
}
}
stage('Build') {
// Build app
steps {
script {
docker.image('nodetools-isis2603:latest').inside('-u root') {
sh '''
CYPRESS_INSTALL_BINARY=0 npm install
npm i -s
ng build
'''
}
}
}
}
stage('Test') {
steps {
script {
docker.image('nodetools-isis2603:latest').inside('-u root') {
sh '''
java -version
npm run test
./node_modules/sonarqube-scanner/bin/sonar-scanner
'''
}
}
}
}
stage('Static Analysis') {
// Run static analysis
steps {
sh '''
docker run --rm -u root -e SONAR_HOST_URL=${SONARQUBE_URL} -e SONAR_TOKEN=${SONAR_TOKEN} -v ${WORKSPACE}:/usr/src sonarsource/sonar-scanner-cli
'''
}
}
}
post {
always {
// Clean workspace
cleanWs deleteDirs: true
}
}
}