From b89f8d9ea832c0631ab3d8c0703035a93de9a5fd Mon Sep 17 00:00:00 2001 From: Anupong Hompan Date: Mon, 27 Oct 2025 23:25:17 +0700 Subject: [PATCH] JK --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8ebe3e5..92e9c46 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ pipeline { docker { image 'mcr.microsoft.com/dotnet/sdk:9.0' args '-u root:root' + label "${params.AGENT_LABEL?.trim() ?: ''}" } } @@ -17,6 +18,7 @@ pipeline { parameters { string(name: 'GIT_URL', defaultValue: 'file:///SourceCode/repos/AS400API.git', description: 'Git repository URL to clone') string(name: 'GIT_BRANCH', defaultValue: 'main', description: 'Branch or ref to build') + string(name: 'AGENT_LABEL', defaultValue: 'docker', description: 'Label of the Jenkins agent that has Docker CLI access') } environment { @@ -183,7 +185,13 @@ pipeline { post { always { - deleteDir() + script { + try { + deleteDir() + } catch (org.jenkinsci.plugins.workflow.steps.MissingContextVariableException ignore) { + echo 'Workspace cleanup skipped because no workspace was provisioned.' + } + } } } }