Skip to content

Commit 0939222

Browse files
authored
Merge pull request #568 from keegangroth/kubernetes-true
Allow declaration of kubernetes agent with no config
2 parents 48f32d5 + ca7e676 commit 0939222

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/main/groovy/com/lesfurets/jenkins/unit/declarative/AgentDeclaration.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class AgentDeclaration extends GenericPipelineDeclaration {
5555
this.docker = createComponent(DockerAgentDeclaration, closure)
5656
}
5757

58+
def kubernetes(boolean _) {
59+
kubernetes([:])
60+
}
61+
5862
def kubernetes(Object kubernetesAgent) {
5963
this.@kubernetes = kubernetesAgent as KubernetesAgentDeclaration
6064
}

src/test/groovy/com/lesfurets/jenkins/unit/declarative/TestDeclarativePipeline.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,13 @@ class TestDeclarativePipeline extends DeclarativePipelineTest {
639639
assertJobStatusSuccess()
640640
}
641641

642+
@Test void should_kubernetes_default_agent() throws Exception {
643+
runScript('Kubernetes_Default_Jenkinsfile')
644+
printCallStack()
645+
assertCallStack().contains('Executing on agent [kubernetes')
646+
assertJobStatusSuccess()
647+
}
648+
642649
@Test void should_credentials() throws Exception {
643650
addCredential('my-prefined-secret-text', 'something_secret')
644651
runScript('Credentials_Jenkinsfile')
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pipeline {
2+
agent { kubernetes true }
3+
stages {
4+
stage('Example Test') {
5+
steps {
6+
echo 'Hello, JDK'
7+
sh 'java -version'
8+
}
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)