I write script for deploy files by ssh via Jenkins
#!groovy
node('superhost01'){
String HOSTNAME="host01"
String USERNAME="tech_user"
withEnv(['PATH=/data/jdbc_connector'])
stage('Prepare') {
checkout scm
}
stage('Deploy') {
sh """
scp -r config.yaml ${USERNAME}@${HOSTNAME}:$PATH
"""
}
}
BUT Jenkins returned error in line
withEnv(['PATH=/data/jdbc_connector'])
error:
[Pipeline] node
Running on superhost01 in /data/jenkins/workspace/jdbc_connector
[Pipeline] {
[Pipeline] withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
java.lang.IllegalStateException: There is no body to invoke
at org.jenkinsci.plugins.workflow.cps.CpsStepContext.newBodyInvoker(CpsStepContext.java:283)
how to correctly assign the value of a variable?