How to use source command within Jenkins pipeline script

前端 未结 3 2066
我在风中等你
我在风中等你 2021-02-12 13:42

I recently rewrite bash execution command into Jenkins pipeline. The old code is like

...
source environment.sh
//Build
//Test
...

Now I use pi

相关标签:
3条回答
  • 2021-02-12 14:05

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

    0 讨论(0)
  • 2021-02-12 14:06

    Replace source environment.sh with

    . ./environment.sh
    

    Please note there is a space after first dot.

    0 讨论(0)
  • 2021-02-12 14:19

    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
        ...
    '''
    
    0 讨论(0)
提交回复
热议问题