Jenkins slaves workspaces

◇◆丶佛笑我妖孽 提交于 2021-02-10 23:41:36

问题


I have a Jenkins multi-configuration project that I want to build on two slaves (Slave-1 and Slave-2) which are located on two different VM's. I am having a problem with how Jenkins attempts to create different workspaces for each slave. I want to use the same workspace path on each VM.

I am getting my project files from Perforce and want to put them in the directory c:\workspace on both VM's. However when I run a build, I look on the VM that has Slave-1 and it stores the project files under:

c:\workspace\label\Slave-1

On the other VM the project files is under:

c:\workspace\label\Slave-2

The folder 'label' under c:\workspace was the slave name I input for the configuration matrix.

How do I override Jenkins to put my project files under c:\workspace on each VM (without the \label\Slave_name folders)? I understand Jenkins does this to avoid confusion but my workspaces are on completely different VM's that won't interact with each other in any way. I have to use the c:\workspace directory in order to build properly.


回答1:


You can start Jenkins with extra params:

-Dhudson.model.Slave.workspaceRoot=c:\workspace

Taken from here: https://issues.jenkins-ci.org/browse/JENKINS-12667




回答2:


Terms:

UnifiedDir: the target dir that you want to use that is the same on both VMs Workspace: the dir that Jenkins creates that is unique to each VM

To get around the workspace isolation and unique naming, your build script should copy the entire workspace (or what you need from it) into the target unified directory. Then a Second call in your "Workspace\Build SCript" should call the "UnifiedDir\Build Script"

Now you have a unified workspace between build nodes. Just make sure you nuke the contents of this UnifiedDir BEFORE you copy the WORKSPACE contents over.



来源:https://stackoverflow.com/questions/30223282/jenkins-slaves-workspaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!