Skip to content

Commit 493cac6

Browse files
authored
chore(pipeline): split Build and Test stage (#562)
Having separate stages allows a better understanding of the potential gains on each of those part when improving the building process. Notes: - Generated docker compose files are archived even if the tests fail - As the `publish` target includes building the images, no need to call it first when only that one is running on trusted.ci.jenkins.io - As there is no "test" phase for multi-arch build, no need to change it
1 parent 585b488 commit 493cac6

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Jenkinsfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,20 @@ def parallelStages = [failFast: false]
8888
}
8989
}
9090
} else {
91-
stage('Build and Test') {
92-
// ci.jenkins.io builds (e.g. no publication)
91+
// ci.jenkins.io builds (e.g. no publication)
92+
stage('Build') {
9393
if (isUnix()) {
9494
sh 'make build'
95+
} else {
96+
powershell '& ./build.ps1 build'
97+
archiveArtifacts artifacts: 'build-windows_*.yaml', allowEmptyArchive: true
98+
}
99+
}
100+
stage('Test') {
101+
if (isUnix()) {
95102
sh 'make test'
96103
} else {
97104
powershell '& ./build.ps1 test'
98-
archiveArtifacts artifacts: 'build-windows_*.yaml', allowEmptyArchive: true
99105
}
100106
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'target/**/junit-results.xml')
101107
}

build.ps1

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,17 @@ if ((Test-Path $dockerComposeFile) -and -not $OverwriteDockerComposeFile) {
168168
Write-Host '= PREPARE: List of images and tags to be processed:'
169169
Invoke-Expression "$baseDockerCmd config"
170170

171-
Write-Host '= BUILD: Building all images...'
172-
switch ($DryRun) {
173-
$true { Write-Host "(dry-run) $baseDockerBuildCmd" }
174-
$false { Invoke-Expression $baseDockerBuildCmd }
175-
}
176-
Write-Host '= BUILD: Finished building all images.'
171+
if ($target -eq 'build') {
172+
Write-Host '= BUILD: Building all images...'
173+
switch ($DryRun) {
174+
$true { Write-Host "(dry-run) $baseDockerBuildCmd" }
175+
$false { Invoke-Expression $baseDockerBuildCmd }
176+
}
177+
Write-Host '= BUILD: Finished building all images.'
177178

178-
if($lastExitCode -ne 0) {
179-
exit $lastExitCode
179+
if($lastExitCode -ne 0) {
180+
exit $lastExitCode
181+
}
180182
}
181183

182184
if($target -eq 'test') {

0 commit comments

Comments
 (0)