简体   繁体   中英

How to checkout and run pipeline file from TFS on specific node in Jenkins?

I am trying to run a pipeline job that get its' pipeline file from TFS but the mapping of the workspace and the checkout is done on the Master instead of the Slave.

I have Jenkins-master which is installed on a linux machine and I connected a windows machine as a slave to it. I created a pipeline job with ' Pipeline script from SCM ' option selected for TFS.
How can I make the windows slave run that pipeline job ?

The master can't run that job because it is running on linux and it fails when it is trying to map a workspace to TFS in order to download the pipeline script and run it.
Even if I create another pipeline job and select to hard-code a script to run my original pipeline job like this:

node('WIN_SLAVE') {
      build job: 'My_Pipeline'
}  

It doesn't work.

And I can see in the output that the initiali script (above) is in fact running on my windows slave, but when it's building the job 'My_Pipeline' it still tries to map a workspace to the Jenkins-master at it's linux machine path /var/jenkins/... and it fails.

If the initial pipeline script ran at the windows slave, why does the other pipeline script not running on the same node? Why is it trying again to checkout the pipeline file from TFS to the Jenkins-Master?

How can I make the windows slave checkout the pipeline file and run it?

Here are some things to check...

  1. Make sure you disabled the original job, or you are completely redefining it for running on the slave, because you indicated you set up “another job” for the slave. It appears that this other job is just triggering the previous job, rather than defining its own specifications. When the job is ran on the slave, it's just running whatever settings are in that original job.

Also, If you have the box checked to build when a change is pushed to TFS, then your original job could still be trying to run every time a change is made to TFS.

  1. Verify the slaves Remote root directory is set properly in the slave configuration under Manage Jenkins -> Manage Nodes.

Since this slave job is triggering the other job you originally created on the master, then it will build on the master as expected.

Instead of referencing the My_Pipeline job, change the My_Pipeline job itself to run on the slave. If you are using a declarative Pipeline for the original job, then change that original job to run on the slave within the original job settings. You can do it similarly to how you have indicated above, just define the node in the original job.

If the original job is a freestyle project, there is a checkbox titled Restrict where this project can be run . Check that and include the name of the slave in the Label Expression. When you run the job, it will then be restricted to the slave.

Lastly, posting the My_Pipeline job will be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM