-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
83 lines (80 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
pipeline {
agent any
environment {
GIT_REPO = '202210_S2_E3_Discomovil_Front'
GIT_CREDENTIAL_ID = 'de5cd571-10da-4034-8ba8-af99beef4b14'
SONARQUBE_URL = 'http://172.24.100.52:8082/sonar-isis2603'
}
stages {
stage('Checkout') {
steps {
scmSkip(deleteBuild: true, skipPattern:'.*\\[ci-skip\\].*')
git branch: 'master',
credentialsId: env.GIT_CREDENTIAL_ID,
url: 'https://github.com/Uniandes-isis2603/' + env.GIT_REPO
}
}
stage('Git Analysis') {
// Run git analysis
steps {
script {
docker.image('gitinspector-isis2603').inside('--entrypoint=""') {
sh '''
mkdir -p ./reports/
datetime=$(date +'%Y-%m-%d_%H%M%S')
gitinspector --file-types="cs,js,asax,ascx,asmx,aspx,html,fs,ts" --format=html --RxU -w -T -x author:Bocanegra -x author:estudiante > ./reports/index.html
'''
}
}
withCredentials([usernamePassword(credentialsId: env.GIT_CREDENTIAL_ID, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh('git config --global user.email "[email protected]"')
sh('git config --global user.name "ci-isis2603"')
sh('git add ./reports/index.html')
sh('git commit -m "[ci-skip] GitInspector report added"')
sh('git pull https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/Uniandes-isis2603/${GIT_REPO} master')
sh('git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/Uniandes-isis2603/${GIT_REPO} master')
}
}
}
stage('Build') {
// Build app
steps {
script {
docker.image('citools-isis2603:latest').inside('-u root') {
sh '''
npm i -s
npm i [email protected]
ng build
'''
}
}
}
}
stage('Test') {
steps {
script {
docker.image('citools-isis2603:latest').inside('-u root') {
sh '''
ng test --watch=false --code-coverage true
npm run sonar
'''
}
}
}
}
stage('Static Analysis') {
// Run static analysis
steps {
sh '''
docker run --rm -u root -e SONAR_HOST_URL=${SONARQUBE_URL} -v ${WORKSPACE}:/usr/src sonarsource/sonar-scanner-cli:4.3
'''
}
}
}
post {
always {
// Clean workspace
cleanWs deleteDirs: true
}
}
}