Unable to check in files to perforce from Jenkins node

405 Views Asked by At

We are writing a new plugin for Jenkins and one of the requirement involves uploading generated files to perforce. I am able to submit to perforce if my files reside on the master but not if they reside on the slave agent(Jenkins node). Error : File not found. We did try using FilePath. We have a doubt that this is because the client is being created from the master. Here is the code:

IOptionsServer srvr = ServerFactory.getOptionsServer("p4java://" + Port, null); 
srvr.connect(); 
srvr.setUserName(User); 
srvr.login(Password); 

IClient client = new Client(srvr); 
client.setName(tmpClientName); 
client.setRoot(source.getRemote()); 
client.setOwnerName(p4User); 
client.setServer(srvr); 
client.setStream("StreamName"); 

ClientView mapping = new ClientView(); 
mapping.addEntry(new ClientView.ClientViewMapping(0,destination, "//" + tmpClientName + "/" + source.getName())); 
client.setClientView(mapping); 
try{ 
    srvr.createClient(client); 
    srvr.setCurrentClient(client);
}

Can anyone help with how to create client from node? or any other insights?

1

There are 1 best solutions below

2
On

It would be helpful if you included what the error you got was. By default, when you create a Perforce client it sets the Host: field to the hostname it was created on, which restricts its use to that host. Take a look at the clients you are generating and see if that field is set.