Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error when using empty agent label #414

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AgentDeclaration extends GenericPipelineDeclaration {
def execute(Object delegate) {
def agentDesc = null

if (label) {
if (label != null) {
agentDesc = '[label:' + label.toString() + ']'
}
else if (docker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,4 +647,12 @@ class TestDeclarativePipeline extends DeclarativePipelineTest {
assertCallStack().contains('echo(Deploy to someLabel)')
assertJobStatusSuccess()
}

@Test void should_agent_with_empty_label() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test failed prior to making the suggested code change.

runScript('AgentEmptyLabel_Jenkinsfile')
printCallStack()
assertCallStack().contains('[label:]')
assertCallStack().contains('echo(Hello using custom workspace and empty label)')
assertJobStatusSuccess()
}
}
15 changes: 15 additions & 0 deletions src/test/jenkins/jenkinsfiles/AgentEmptyLabel_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pipeline {
agent {
node {
label ''
customWorkspace "myworkspace"
}
}
stages {
stage('Example Build') {
steps {
echo "Hello using custom workspace and empty label"
}
}
}
}