Run a command shell in jenkins

前端 未结 6 2125
甜味超标
甜味超标 2020-12-16 10:08

I\'m trying to execute a command shell in Jenkins, I\'m working on Windows 7. In the console output I have this:

Building in workspace C:\\Program Files (x86         


        
6条回答
  •  情深已故
    2020-12-16 10:58

    As far as I know, Windows will not support shell scripts out of the box. You can install Cygwin or Git for Windows, go to Manage Jenkins > Configure System Shell and point it to the location of sh.exe file found in their installation. For example:

    C:\Program Files\Git\bin\sh.exe
    

    There is another option I've discovered. This one is better because it allowed me to use shell in pipeline scripts with simple sh "something".

    Add the folder to system PATH. Right click on Computer, click properties > advanced system settings > environmental variables, add C:\Program Files\Git\bin\ to your system Path property.

    IMPORTANT note: for some reason I had to add it to the system wide Path, adding to user Path didn't work, even though Jenkins was running on this user.

    An important note (thanks bugfixr!):

    This works. It should be noted that you will need to restart Jenkins in order for it to pick up the new PATH variable. I just went to my services and restated it from there.

    Disclaimer: the names may differ slightly as I'm not using English Windows.

提交回复
热议问题