-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathJenkinsfile.internal
97 lines (93 loc) · 3.28 KB
/
Jenkinsfile.internal
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
/**
* SPDX-FileCopyrightText: 2015-2024 tracetronic GmbH <[email protected]>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
=============
Prerequisites
=============
* Maven tool installation configured as M3
* JDK tool installation configured as JDK17
* Global environment variable EMAIL_RECIPIENTS set
* Jenkins plugins installed:
- https://plugins.jenkins.io/jacoco
- https://plugins.jenkins.io/javadoc
- https://plugins.jenkins.io/timestamper
- https://plugins.jenkins.io/warnings-ng
*/
@Library(['tracetronic-jenkins-lib', 'internal-cxs-jenkins-lib']) _
pipeline {
options {
buildDiscarder(logRotator(daysToKeepStr: '14'))
timestamps()
}
agent any
environment {
authKey = credentials('TG_authkey_test_report_upload')
pipeline_report_dir = "report2TG/build-$env.BUILD_NUMBER"
PRODUCT_NAME = "ecutest-plugin"
PRODUCT_VERSION = readMavenPom().getVersion()
TEST_LEVEL = "unit"
}
tools {
maven 'M3'
}
stages {
stage('Build') {
steps {
mvn 'clean package -DskipUTs'
archiveArtifacts artifacts: 'target/*.hpi', fingerprint: true
}
}
stage('Static Code Analysis') {
steps {
mvn 'checkstyle:check pmd:check pmd:cpd-check spotbugs:check'
recordIssues(tools: [
checkStyle(pattern: 'target/checkstyle-result.xml'),
pmdParser(pattern: 'target/pmd.xml'),
cpd(pattern: 'target/cpd.xml'),
spotBugs(pattern: 'target/spotbugsXml.xml', useRankAsPriority: true),
taskScanner(includePattern: 'src/**/*.java', normalTags: 'TODO', highTags: 'FIXME')])
}
}
stage('Unit Tests') {
steps {
mvn 'jacoco:prepare-agent surefire:test -Dsurefire.useFile=false'
junit 'target/surefire-reports/TEST-*.xml'
Xml2TG((long) currentBuild.startTimeInMillis, "target/surefire-reports", "JUnit","uploadJson", [:], [:], "${TESTGUIDE_url}", "${authKey}", "${TESTGUIDE_projectID}")
jacoco exclusionPattern: '**/Messages.class', execPattern: 'target/jacoco.exec'
}
}
stage('Docs') {
steps {
mvn 'javadoc:javadoc'
step([$class: 'JavadocArchiver', javadocDir: 'target/reports/apidocs', keepAll: false])
}
}
}
post {
always {
dir("${pipeline_report_dir}") {
pipeline2ATX(true)
}
uploadJson2TG("${TESTGUIDE_url}", "${authKey}", "${TESTGUIDE_projectID}", "${pipeline_report_dir}/**", '')
}
unsuccessful {
mail to: "${env.EMAIL_RECIPIENTS}",
subject: "${JOB_NAME} - Build #${BUILD_NUMBER} - ${currentBuild.currentResult}",
body: "Check console output at ${BUILD_URL} to view the results."
}
}
}
def mvn(def args) {
def mvnHome = tool 'M3'
def javaHome = tool 'JDK17'
withEnv(["JAVA_HOME=${javaHome}", "PATH+MAVEN=${mvnHome}/bin:${env.JAVA_HOME}/bin"]) {
if (isUnix()) {
sh "${mvnHome}/bin/mvn ${args} -B -V -U -e"
} else {
bat "${mvnHome}\\bin\\mvn ${args} -B -V -U -e"
}
}
}