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 {
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