Pass shell variable to mongodb script Pass shell variable to mongodb script jenkins jenkins

Pass shell variable to mongodb script


You are preventing the variable interpolation by using \ before EOF. See https://tldp.org/LDP/abs/html/here-docs.html:

Quoting or escaping the "limit string" at the head of a here document disables parameter substitution within its body. The reason for this is that quoting/escaping the limit string effectively escapes the $, `, and \ special characters, and causes them to be interpreted literally.

serene% a=1serene% cat <<Theredoc> $aheredoc> T1serene% cat <<\Theredoc> $aheredoc> T$a

Remove the backslash if you want interpolation to happen.