Skip to content

Commit

Permalink
chore: improve environment variable scopes and retrieval of VERSION
Browse files Browse the repository at this point in the history
… as env var in build.ps1
  • Loading branch information
lemeurherve committed Jun 10, 2024
1 parent bad0642 commit 237f698
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
def agentSelector(String imageType) {
// Image type running on a Linux agent
// Linux agent
if (imageType == 'linux') {
return 'linux'
}
// Image types running on a Windows Server Core 2022 agent
// Windows Server Core 2022 agent
if (imageType.contains('2022')) {
return 'windows-2022'
}
// Remaining image types running on a Windows Server Core 2019 agent: (nanoserver|windowservercore)-(1809|2019)
// Windows Server Core 2019 agent (for nanoserver 1809 & ltsc2019 and for windowservercore ltsc2019)
return 'windows-2019'
}

Expand All @@ -20,6 +20,9 @@ pipeline {

stages {
stage('docker-ssh-agent') {
environment {
DOCKERHUB_ORGANISATION = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}"
}
matrix {
axes {
axis {
Expand All @@ -35,9 +38,6 @@ pipeline {
options {
timeout(time: 60, unit: 'MINUTES')
}
environment {
DOCKERHUB_ORGANISATION = "${infra.isTrusted() ? 'jenkins' : 'jenkins4eval'}"
}
stages {
stage('Prepare Docker') {
when {
Expand Down Expand Up @@ -78,18 +78,18 @@ pipeline {
when {
buildingTag()
}
environment {
ON_TAG = 'true'
VERSION = "${env.TAG_NAME}"
}
steps {
script {
// This function is defined in the jenkins-infra/pipeline-library
infra.withDockerCredentials {
if (isUnix()) {
sh """
export ON_TAG=true
export VERSION=$TAG_NAME
docker buildx bake --push --file docker-bake.hcl linux
"""
sh ' docker buildx bake --push --file docker-bake.hcl linux'
} else {
powershell "& ./build.ps1 -VersionTag ${env.TAG_NAME} publish"
powershell '& ./build.ps1 -VersionTag publish'
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ if(![String]::IsNullOrWhiteSpace($env:DOCKERHUB_ORGANISATION)) {
$Organisation = $env:DOCKERHUB_ORGANISATION
}

if(![String]::IsNullOrWhiteSpace($env:VERSION)) {
$VersionTag = $env:VERSION
}

if(![String]::IsNullOrWhiteSpace($env:IMAGE_TYPE)) {
$ImageType = $env:IMAGE_TYPE
}
Expand Down

0 comments on commit 237f698

Please sign in to comment.