Skip to content

Commit

Permalink
chore: improve env var scopes and retrieve VERSION in build.ps1 (#424)
Browse files Browse the repository at this point in the history
* chore: improve env var scopes and retrieve `VERSION` as env var in build.ps1

* remove extraneous space
  • Loading branch information
lemeurherve authored Jun 18, 2024
1 parent 8e82638 commit 3b45fbd
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 @@ -75,18 +75,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}"
make publish
'''
sh 'make publish'
} else {
powershell '& ./build.ps1 -VersionTag $env:TAG_NAME publish'
powershell '& ./build.ps1 publish'
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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 3b45fbd

Please sign in to comment.