0

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 Answers1

0

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.

Drew Marold
  • 175
  • 6
  • Error : File not found. The host field was empty. we tried setting it to that of the node but it did not help. – user3628860 Feb 07 '17 at 09:06
  • What is it trying to do when you get the file not found, is that during the 'p4 add'? One thing to look at is if the path to the client root is the same on the master and the slave. If you're passing an absolute path to 'p4 add' and it's not the same for both, that would do it. – Drew Marold Feb 08 '17 at 14:17