0

I am tring to run an ansible shell script thorugh a groovy script in Jenkins. But I am getting weird syntax error when I use special characters like $ or . I tried to use the escape sequence but still getting an error. It works fine if I remove the JAVA_OPTS variable.

batch_service_url="http://DEV:8080/test" JAVA_OPTS="\$JAVA_OPTS -Dactivemq.tcp.url=failover:\(tcp://DEV1:61616,tcp://DEV1:61616\)?nested.wireFormat.maxInactivityDuration=30000"

    def test(){

    sh """sudo w360ansibleint <<EOF      
    ansible-playbook -i ansible/ANS-5.2.0/hosts ansible/ANS-5.2.0/app_config.yml -e '{
    "ansible_hostname":"${ansible_hostname}",
    "tomcat_app_parameters":"base",
    "batch_service_url":"${batch_service_url}",
    "tomcat_setenv_extra": ["\\$JAVA_OPTS"]

      }'

EOF """
}

StephenKing
  • 36,187
  • 11
  • 83
  • 112
  • Possible duplicate of [Getting bad substitution error when bumping up version using maven versions plugin in Jenkins pipeline](https://stackoverflow.com/questions/52399604/getting-bad-substitution-error-when-bumping-up-version-using-maven-versions-plug) – Michael Sep 30 '18 at 07:19
  • Welcome to StackOverflow. Properly formatting your question would make it a bit more welcoming for readers.. – StephenKing Sep 30 '18 at 13:31

0 Answers0