Skip to content

Commit

Permalink
Merge pull request #568 from keegangroth/kubernetes-true
Browse files Browse the repository at this point in the history
Allow declaration of kubernetes agent with no config
  • Loading branch information
nre-ableton authored Jan 11, 2023
2 parents 48f32d5 + ca7e676 commit 0939222
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class AgentDeclaration extends GenericPipelineDeclaration {
this.docker = createComponent(DockerAgentDeclaration, closure)
}

def kubernetes(boolean _) {
kubernetes([:])
}

def kubernetes(Object kubernetesAgent) {
this.@kubernetes = kubernetesAgent as KubernetesAgentDeclaration
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,13 @@ class TestDeclarativePipeline extends DeclarativePipelineTest {
assertJobStatusSuccess()
}

@Test void should_kubernetes_default_agent() throws Exception {
runScript('Kubernetes_Default_Jenkinsfile')
printCallStack()
assertCallStack().contains('Executing on agent [kubernetes')
assertJobStatusSuccess()
}

@Test void should_credentials() throws Exception {
addCredential('my-prefined-secret-text', 'something_secret')
runScript('Credentials_Jenkinsfile')
Expand Down
11 changes: 11 additions & 0 deletions src/test/jenkins/jenkinsfiles/Kubernetes_Default_Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pipeline {
agent { kubernetes true }
stages {
stage('Example Test') {
steps {
echo 'Hello, JDK'
sh 'java -version'
}
}
}
}

0 comments on commit 0939222

Please sign in to comment.