Hi

The following Jenkins pipeline script is not working and we will get as 
error

ERROR
WorkflowScript: 20: Expected string literal @ line 20, column 11.
       agent checkEnvironment()
             ^

WorkflowScript: 20: Only "agent none", "agent any" or "agent {...}" are 
allowed. @ line 20, column 5.
       agent checkEnvironment()

CODE

@Library('snowdrop-lib') _

def checkEnvironment() {
  stage("main") {
    node {
      if (fileExists('/var/run/secrets/kubernetes.io')) {
        AGENT_DEF = """kubernetes {
                            |  defaultContainer 'jnlp'
                            |  yaml 
libraryResource('./podTemplates/multi-containers.yml')
                            |}""".stripMargin()
      } else {
        AGENT_DEF = "label any"
      }
      return AGENT_DEF
    }
  }  
}

pipeline {
    agent checkEnvironment()
    ...

Question: Can we do something like this ? If yes - How ? Example ?

Cheers

Charles

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8fe8cb92-b02c-4f1d-9b63-5a7b2af5f2e6n%40googlegroups.com.

Reply via email to