Skip to content

Commit

Permalink
feat(jenkins): Allow to pass Docker build arguments as job parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Feb 13, 2024
1 parent 959902c commit e8e68aa
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions integrations/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import java.io.IOException

import org.jenkinsci.plugins.pipeline.modeldefinition.Utils

@Field
final DOCKER_BUILD_ARGS = '--build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --build-arg ORT_VERSION='

// Disable the entry point to work around https://issues.jenkins-ci.org/browse/JENKINS-51307.
final DOCKER_RUN_ARGS = '-e http_proxy -e https_proxy --entrypoint=""'

Expand All @@ -43,7 +40,9 @@ def ortVersion = 'JENKINS-SNAPSHOT'

@NonCPS
def getDockerBuildArgs() {
return DOCKER_BUILD_ARGS + ortVersion
def defaultArgs = ['http_proxy=$http_proxy', 'https_proxy=$https_proxy', "ORT_VERSION=$ortVersion"]
def customArgs = params.CUSTOM_DOCKER_BUILD_ARGS.tokenize(',')
return (defaultArgs + customArgs).collect { "--build-arg ${it.trim()}" }.join(' ')
}

@NonCPS
Expand All @@ -55,6 +54,16 @@ pipeline {
agent none

parameters {
/*
* Parameters about the project to run ORT on.
*/

string(
name: 'CUSTOM_DOCKER_BUILD_ARGS',
description: 'A comma-separated list of arguments to pass to the Docker build, e.g. "JAVA_VERSION=17,SCANCODE_VERSION=32.0.8".',
defaultValue: ''
)

/*
* Parameters about the project to run ORT on.
*/
Expand Down

0 comments on commit e8e68aa

Please sign in to comment.