Fifteen Stars

Talend Metaservlet API: associatePreGeneratedJob action

I have been using the metaservlet for a while to run tasks and it is working fine. However I have tried to create a task for a job that is stored in Nexus and am getting errors with everything I try. I am using the associatePreGeneratedJob action to do this since this appears to be the only action that supports setting up a task from Nexus. However, the issue I am having is that it fails with the "FilePath" parameter. Given the Nexus parameters, the "FilePath" parameter seems pointless. But I have tried every filepath that *could* correspond to the file's location in Nexus. No dice. Has anyone got this working? Do you have to copy the zip file from Nexus to a known location before using it (if so WHY?!?). Is this a bug? I am using 6.1 at the moment but will be moving to 6.2 soon.
My JSON is structured as below (but with different settings).
{
 
"actionName":"associatePreGeneratedJob",
"active": true,
"authPass": "admin",
"authUser":"admin@company.com",
"contextName": "Default",  
"description":"task1's description",  
"executionServerName":"serv1",  
"filePath":"'/home/talend/generatedJob.zip'",  
"importType":"Nexus",  
"logLevel":"Info",  
"nexusArtifactId":"test",  
"nexusGroupId":"org.example",  
"nexusRepository":"snapshots",  
"nexusVersion":"0.1.0-SNAPSHOT",  
"onUnknownStateJob":"WAIT",  
"pauseOnError":false,  
"taskName":"task1",  
"timeout":3600
}

I have left the filepath as is, I have removed it and I have just left it blank. Nothing is working.
Rilhia Solutions
5 REPLIES
One Star

Re: Talend Metaservlet API: associatePreGeneratedJob action

I was able to publish a nexus job in talend 6.2.1 with the following json.  Some helpful notes...
- Publish the job manually in the TAC to see values for the Nexus fields (GroupID, ArtifactID, etc)
- Make sure your user has the right permissions to get the job from nexus (Designer?), and to publish to the correct project
- print the results from the metaservlet call, it can have some helpful information
I hope this helps
{
  "actionName": "associatePreGeneratedJob",
  "active": true,
  "authPass": "adminpassword1",
  "authUser": "admin@company.com",
  "description": "task1's description",
  "executionServerName": "DEV",
  "filePath": "HelloWorld",
  "importType": "Nexus",
  "logLevel": "Info",
  "nexusArtifactId": "HelloWorld",
  "nexusGroupId": "POC",
  "nexusRepository": "talendrelease",
  "nexusVersion": "1.3.0",
  "onUnknownStateJob": "WAIT",
  "pauseOnError": false,
  "taskName": "PYTHONTASK",
  "timeout": 3600
}
Fifteen Stars

Re: Talend Metaservlet API: associatePreGeneratedJob action

Thanks for your response. Unfortunately I have tried practically everything you suggested (and have just tried it again). I do have a question though. You have "HelloWorld" as your filepath. What made you select that? Did you just choose to use the "NexusArtifactId" or is the value the same by coincidence? I believe that it is this value that is preventing this from working since the error I get is....
"file is not a valid file or not exist"
I am also curious about how you came up with "HelloWorld" for the filepath because the Talend documentation shows this.... 

----------------------------------------------------------
Command: associatePreGeneratedJob
----------------------------------------------------------
Description : Create a new execution task with a pre-generated zip file
- targetConductor: could be . "JOBCONDUCTOR" is the default value.
- importType: the position where select the zip file from; Nexus' or 'File', default value is 'File'
Requires authentication : true
Since : 5.2
Sample :
{

"actionName": "associatePreGeneratedJob",
"active": true,
"authPass": "admin",
"authUser": "admin@company.com",
"contextName": "Default",
"description":"task1's description",
"executionServerName": "serv1",
"filePath": "'/home/talend/generatedJob.zip'",
"importType": "Nexus",
"logLevel": "Info",
"nexusArtifactId": "test",
"nexusGroupId": "org.example",
"nexusRepository": "snapshots",
"nexusVersion": "0.1.0-SNAPSHOT",
"onUnknownStateJob": "WAIT",
"pauseOnError": false,
"taskName": "task1",
"timeout": 3600
}
Specific error codes :

180: file is not a valid file or not exist

181: nexus parameters may be not correct



As you can see the filepath seems to be pointing to a file on a filesystem somewhere and it specifies the type (zip).
Are there any Talend employees who can maybe shed a bit of light on this? Can I also make the suggestion that more examples are
given in the API documentation?
Rilhia Solutions
Fifteen Stars

Re: Talend Metaservlet API: associatePreGeneratedJob action

It turns out that the reason I have had issues is that this functionality is not supported until 6.2.1. I am using 6.1.1. Even though the API documentation says it has been available since 5.2. Sigh....
Rilhia Solutions
One Star

Re: Talend Metaservlet API: associatePreGeneratedJob action

Yes, I just chose that to match up to the nexusArtifactId.  I assumed that the filePath was not relevant when using the Nexus importType.
If it's possible, perhaps you can intercept the calls to Nexus to see what HTTP API call is being made.  Maybe you could use that to determine what Talend is sending, versus what Nexus is getting.
On another note, related to this functionality.  I'm trying to get a job loaded into a different project then what is specified in the .zip file's jobinfo.properties file.  Put another way, if the job is published from the POCDEV project, then it would be great to be able to load it into the POCTEST project.  The thought is to migrate a single nexus job across DEV, TEST, STAGING, QA, PROD, etc environments.
Fifteen Stars

Re: Talend Metaservlet API: associatePreGeneratedJob action

I spoke to support today TalendUser0001. They said that it won't work in 6.1.1. Apparently their documentation needs looking at since it says that it will. The first version this works in is 6.2. We are upgrading soon and I suspect what I originally had will work. Thanks for your input :-)
Rilhia Solutions