I am having Jenkins master and two slaves named slave1 and slave2. I want to execute some shell commands on slave1 and some shell commands on slave2 in the same job. How can i do this...?
You need to create a multi-configuration job in jenkins as step 1. In a multi configuration job you can run the same job on two or more slaves for a single run.
for this you need to use a if condition and check if the job is executing on intended slave if yes execute the shell else skip execution.
Now how to find if my job is executing on which slave , you can use jenkins pre-defined environment variable NODE_NAME.
[[ $NODE_NAME == slave1 ]] && echo code executes.
you can write something similar to above and get the required thing done.