I have an Jenkins with AWS integration where all the agents node are created dynamically.
My issue is when I use the "martix" statement and use the "when" to filter OSes that are not needed to be built, the nodes are still created then skip by when statement. Is there a way to apply the "when" statement to filter so only nodes are required is created?
Below is my pipeline code and if I shoose ubuntu platform, windows and macos node still gets created but nothing runs since its filtered by the when condition.
pipeline { parameters { choice(name: 'PLATFORM_FILTER', choices: ['ubuntu', 'windows', 'macos', 'all'], description: 'Run on specific platform') } agent none stages { stage('CI pipeline') { matrix { when { anyOf { expression { params.PLATFORM_FILTER == 'all' } expression { params.PLATFORM_FILTER == env.PLATFORM } } } agent { label "${PLATFORM}-agent" } axes { axis { name 'PLATFORM' values 'ubuntu', 'windows', 'macos' } }
- duplicates
-
JENKINS-44461 When clause shouldn't require node to evaluate
- Closed