Closed perzizzle closed 5 years ago
Reading harder I see now that you are catching the NumberFormatException.
String apiEndPoint = "/api/v1/job_templates/";
...
HttpResponse response = makeRequest(GET, api_endpoint);
I would expect we want to do a GET on /api/v1/job_templates/?name=HelloWorld, confirm the count is 1 and parse out the results. We have more job templates than ansible tower will return in a single request. I think this solution is better than asking for every single template and implementing pagination.
Think my PR will fix this issue for us and others. The root of the problem was that our company has more than 200 job templates, so they aren't all returned in a single response. This PR will make it much more efficient by using the name in the search.
Resolved by PR
We are starting to work on migrating to jenkins 2.0 and thought this plugin looked useful to replace a custom global library/global variables we had been using. With a step like the following
We always receive: Beginning Ansible Tower Run on Dev Tower ERROR: Unable to lookup job template Job template does not exist in tower
If instead we use the job template id number, the pipeline works.
Browsing through the code I see the method convertPotentialStringToID in TowerConnector. If I'm following this correctly jobTemplate = 'HelloWorld' which is then Integer.parseInt(idToCheck). Since this isn't an integer we don't locate a job template.
Does searching by name work for you?