0
votes

I am a newbie wrt jenkins. So I am sorry if this question is so naive. I would like to execute batch file on windows slave agent from jenkins project/job. Please let me know how to achieve the same.

Following is the log for the same.

Started by user Jenkins Admin Building remotely on slave01 in workspace d:\jenkins\workspace\Test Triggering Test � default Test � default completed with result FAILURE Finished: FAILURE

1
Finally, fixed the issue. I gave the slave agent's work space directory in 'Use custom child workspace'. and it worked fine. - User_3536

1 Answers

1
votes

For Freestyle Project:-

Go to the configure option of the job and follow below (provide the Label of your agent in the Label Expression)

enter image description here

and select the Execute Windows batch command in configure

enter image description here For Pipeline Project:-

Use the below snippet in the jenkins file

stage ('Build') {
            steps {
                node(label: 'AgentName') {
                        bat "batch script location"
                    }
                }
            }