-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
87 lines (85 loc) · 3.04 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
pipeline {
agent any
environment {
GIT_REPO = '202120_S3_E2_Treeking_Back'
GIT_CREDENTIAL_ID = 'de5cd571-10da-4034-8ba8-af99beef4b14'
ARCHID_TOKEN = credentials('041703df-dd96-47c3-97b1-b7fbf12069d5')
SONARQUBE_URL = 'http://172.24.101.209: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="java" --format=html --AxU -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('echo "Report updated" >> ./reports/.status')
sh('git add ./reports/index.html ./reports/.status')
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 artifacts
steps {
script {
docker.image('springtools-isis2603:latest').inside('-v ${WORKSPACE}/maven:/root/.m2') {
sh '''
java -version
./mvnw clean package
'''
}
}
}
}
stage('Testing') {
// Run unit tests
steps {
script {
docker.image('springtools-isis2603:latest').inside('-v ${WORKSPACE}/maven:/root/.m2') {
sh '''
./mvnw clean test
'''
}
}
}
}
stage('Static Analysis') {
// Run static analysis
steps {
script {
docker.image('springtools-isis2603:latest').inside('-v ${WORKSPACE}/maven:/root/.m2') {
sh '''
./mvnw clean verify sonar:sonar -Dsonar.host.url=${SONARQUBE_URL}
'''
}
}
}
}
}
post {
always {
// Clean workspace
cleanWs deleteDirs: true
}
}
}