通过man bash可知:
OPTIONS
In addition to the single-character shell options documented in the description of the set builtin command,
bash interprets the following options when it is invoked:
-c string If the -c option is present, then commands are read from string. If there are arguments after the
string, they are assigned to the positional parameters, starting with $0.
-i If the -i option is present, the shell is interactive.
-l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
-r If the -r option is present, the shell becomes restricted (see RESTRICTED SHELL below).
-s If the -s option is present, or if no arguments remain after option processing, then commands are
read from the standard input. This option allows the positional parameters to be set when invoking
an interactive shell.
-D A list of all double-quoted strings preceded by $ is printed on the standard output. These are the
strings that are subject to language translation when the current locale is not C or POSIX. This
implies the -n option; no commands will be executed.
可以通过-i参数和-l参数让bash为login shell and interactive shell,就可以读取/etc/profile和~/.bash_profile等文件。
即在jenkins Execute Shell里可以这么写
#!/bin/bash -ilex
...
...
对于e参数表示一旦出错,就退出当前的shell,x参数表示可以显示所执行的每一条命令