How to use source command within Jenkins pipeline script

source is a bash/ksh/etc extension, provided as a more "substantial" synonym for ..

In sh, you need to use . in case the underlying shell is one (such as dash) that does not support the command source.

sh '''
    ...
    . ./environment.sh
    //Build
    //Test
    ...
'''

If someone want to execute the script with source only solution is to change "Shell executable" to bash in ->Manage Jenkins->Configure System


Replace source environment.sh with

. ./environment.sh

Please note there is a space after first dot.