-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile.internal
158 lines (146 loc) · 6.58 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* Copyright (c) 2021-2024 tracetronic GmbH
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
=============
Prerequisites
=============
* Global environment variables set:
- EMAIL_RECIPIENTS
- TG_AUTH_KEY
- ET_V1_VERSION
- ET_V2_VERSION
- TG_VERSION
* Jenkins plugins installed:
- https://plugins.jenkins.io/timestamper
- https://plugins.jenkins.io/gradle/
*/
@Library(['tracetronic-jenkins-lib', 'internal-cxs-jenkins-lib']) _
pipeline {
options {
buildDiscarder(logRotator(daysToKeepStr: '14'))
timestamps()
}
agent {
label 'docker && linux' // linux only to keep windows docker runners free, so they can run the systemTests job
}
environment {
authKey = credentials('TG_authkey_test_report_upload')
pipeline_report_dir = "report2TG/build-$env.BUILD_NUMBER"
PRODUCT_NAME = "ecu-test-execution-plugin"
TEST_LEVEL = "pipeline"
JENKINS_VERSION = "2.426.3"
}
tools {
jdk 'JDK17'
}
parameters {
string(name: 'CONTAINER_TEST_DATA_BRANCH', defaultValue: 'main', description: 'The specified branch name to use for testing.')
string(name: 'ET_VERSION', defaultValue: '2023.4.0', description: 'The specified ecu.test version to use for testing.')
string(name: 'ET_V1_VERSION', defaultValue: '2023.3.0', description: 'The specified ecu.test v1 version to use for testing.')
string(name: 'ET_V2_VERSION', defaultValue: '2024.4.0', description: 'The specified ecu.test v2 version to use for testing.')
string(name: 'TG_VERSION', defaultValue: '1.180.0', description: 'The specified test.guide version to use for testing.')
}
stages {
stage ('Set Product Version') {
steps {
script {
echo "Reading properties from gradle.properties"
gradle_properties = readProperties file: 'gradle.properties'
env.PRODUCT_VERSION = gradle_properties['version']
echo "Product Version set to: ${env.PRODUCT_VERSION}"
}
}
}
stage('Unit Tests') {
steps {
catchError(stageResult: 'UNSTABLE', buildResult: 'UNSTABLE') {
cmd '"./gradlew" clean unitTest'
}
}
}
stage('Integration Tests') {
steps {
catchError(stageResult: 'UNSTABLE', buildResult: 'UNSTABLE') {
cmd '"./gradlew" integrationTest'
}
}
}
stage('Publish Code Coverage') {
steps {
jacoco execPattern: '**/build/jacoco/unitTest.exec,**/build/jacoco/integrationTest.exec',
classPattern: '**/build/classes/groovy/main',
sourcePattern: '**/src/main/groovy',
exclusionPattern: '**/build/classes/groovy/test'
}
}
stage('Run Parallel') {
failFast false
parallel {
stage('System Tests') {
// The needed artifact is only built for main and pull requests -> skip this job otherwise
when { branch pattern: "PR-\\d+|main", comparator: "REGEXP"}
steps {
build job: '../systemTests', parameters: [string(name: 'artifactName', value: "${JOB_BASE_NAME}"), string(name: 'commitHash', value: "${GIT_COMMIT}")]
}
}
stage('Container Tests') {
stages {
stage('Prepare Resources') {
steps {
script {
catchError(stageResult: 'UNSTABLE', buildResult: 'UNSTABLE') {
copyArtifacts fingerprintArtifacts: true, projectName: "../containerTestData/${params.CONTAINER_TEST_DATA_BRANCH}", selector: lastSuccessful()
}
def properties = readFile('src/test/resources/containerTest.properties')
.replaceAll(/ET_VERSION=.*/, "ET_VERSION=${params.ET_VERSION}")
.replaceAll(/ET_V1_VERSION=.*/, "ET_V1_VERSION=${params.ET_V1_VERSION}")
.replaceAll(/ET_V2_VERSION=.*/, "ET_V2_VERSION=${params.ET_V2_VERSION}")
.replaceAll(/TG_VERSION=.*/, "TG_VERSION=${params.TG_VERSION}")
writeFile(file: 'src/test/resources/containerTest.properties', text: properties)
}
}
}
stage('Run Container Tests') {
steps {
catchError(stageResult: 'UNSTABLE', buildResult: 'UNSTABLE') {
cmd '"./gradlew" containerTest -Dspock.skip.sandbox=false'
}
}
}
}
}
}
}
}
post {
always {
script {
catchError(stageResult: 'FAILURE', buildResult: 'FAILURE') {
withEnv(["TEST_LEVEL=unit"]) {
Xml2TG((long) currentBuild.startTimeInMillis, "build/test-results/unitTest/", "JUnit", ,"uploadJson", [:], [:], "${TESTGUIDE_url}", "${authKey}", "${TESTGUIDE_projectID}")
}
withEnv(["TEST_LEVEL=integration"]) {
Xml2TG((long) currentBuild.startTimeInMillis, "build/test-results/integrationTest/", "JUnit", ,"uploadJson", [:], [:], "${TESTGUIDE_url}", "${authKey}", "${TESTGUIDE_projectID}")
}
withEnv(["TEST_LEVEL=system"]) {
Xml2TG((long) currentBuild.startTimeInMillis, "build/test-results/containerTest/", "JUnit", ,"uploadJson", [:], [:], "${TESTGUIDE_url}", "${authKey}", "${TESTGUIDE_projectID}")
}
}
}
}
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."
}
cleanup {
dir("${pipeline_report_dir}") {
pipeline2ATX(true)
}
uploadJson2TG("${TESTGUIDE_url}", "${authKey}", "${TESTGUIDE_projectID}", "${pipeline_report_dir}/**", '')
}
}
}