0

I am writing a groovy script in jenkins, and when trying these commands I'm getting different outputs not knowing what exactly the difference and what is the need for each one of these. Furthermore, the output of same commands is different between running it on jenkins or running it in putty terminal connected to jenkins machine, any idea about these issues?

anonymous
  • 37
  • 7
  • 1
    A little code sample would be helpful, because it depends on the context, how the variables are resolved. – zett42 Nov 18 '21 at 14:47
  • 1
    $(pwd) / \`pwd\` are different forms of running the command [`pwd`](https://man7.org/linux/man-pages/man1/pwd.1.html), will return the value of current Working Directory. $pwd / ${pwd} are different forms of using the variable ”pwd". Note: unix is case-sensitive. $PWD / ${PWD} is a built-in variable set by the OS shell with the value of current Working Directory, [which is set](https://man7.org/linux/man-pages/man1/pwd.1p.html#ENVIRONMENT_VARIABLES) every time you [execute] change a directory. There are many answers here and on SE that explain variable usage and command invocation. – Ian W Nov 19 '21 at 04:21
  • great! that makes sense, but still one thing I have doubt about, which is when running sh """ echo $pwd""" in groovy script it prints out a directory though it should print a null value since it should print the value of the variable pwd, right? – anonymous Nov 19 '21 at 08:50
  • As @zett42 suggests, you need to post more context (ie:code). It may be set somewhere. Type env and see if it's a set variable. – Ian W Nov 19 '21 at 09:39

0 Answers0