Issue
Here is my code which I am passing parameter value in my Jenkins Declarative Pipeline, but when I execute getting this error
T@tmp/durable-64ccbb6b/script.sh: line 4: ${params.InputValue}: bad substitution
sh '''
#!/bin/bash -xe
printf '%s\n' /dev/sd{e..z} | head -n "${params.InputValue}" > volumelist.txt
cat volumelist.txt
'''
I tried almost all of google searches for Bad substitution. Still can't get rid of it. Could someone help me out how to resolve this??
Solution
Have a look at Groovy's string interpolation.
tl;dr Use """
instead of '''
:
sh """
printf ${params.InputValue}
"""
Answered By - Michael Kemmerzell
Answer Checked By - Cary Denson (JavaFixing Admin)