VJohn
VJohn

Reputation: 533

How to execute shell commands in windows slave machine from Jenkins?

I have connected windows machine as a slave to a Jenkins job

I have installed gitbash.exe in the windows slave machine

I need to execute shell commands from Jenkins in windows slave

Found some solutions like, Specifying the shell.exe path in the Jenkins > System configuration > executable shell and choose "execute shell" in the build step - But i should not do this as my Jenkins has several jobs configured with different slaves

How can i execute shell commands from Jenkins build step?

Upvotes: 1

Views: 7168

Answers (1)

Chris Riccio
Chris Riccio

Reputation: 681

Jenkins will execute whatever you have in your build steps on the slave that the build runs on. So if you have an "Execute Shell" step in your build, when it runs on any slave it will execute those steps.

the Git Bash shell installs here by default

C:\Program Files\Git\usr\bin

On your windows slave machine, make that directory (or where-ever you installed to) the first item in the PATH (on the windows machine itself, not in jenkins), and restart your slave service

Since jenkins just runs sh.exe to execute the shell commands, it will find it via the PATH on the machine

Upvotes: 2

Related Questions