Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job api to create jobs inside a folder #10

Closed
Dhivyaa21 opened this issue May 3, 2018 · 7 comments
Closed

Job api to create jobs inside a folder #10

Dhivyaa21 opened this issue May 3, 2018 · 7 comments
Assignees
Milestone

Comments

@Dhivyaa21
Copy link
Contributor

Currently, the job Api to create a job is as follows

@Named("jobs:create")
@Path("/createItem")
@Fallback(JenkinsFallbacks.RequestStatusOnError.class)
@ResponseParser(RequestStatusParser.class)
@Produces(MediaType.APPLICATION_XML)
@Consumes(MediaType.WILDCARD)
@Payload("{configXML}")
@POST
RequestStatus create(@QueryParam("name") String jobName,
@PayloadParam(value = "configXML") String configXML);

This API creates a job in jenkins root folder but not inside a folder.

Perhaps, we can add another API to with a pathparam like @Path("{pathToJob}/createItem") to support the creation of jobs inside a folder.

@cdancy cdancy self-assigned this May 3, 2018
@cdancy cdancy added this to the v0.0.7 milestone May 3, 2018
@cdancy
Copy link
Owner

cdancy commented May 3, 2018

@Dhivyaa21 that sounds like a great idea. Maybe something like createWithPath(...) would do? Care to send in a PR?

@martinda you've been working in this space recently and may have some thoughts one way or another.

@Dhivyaa21
Copy link
Contributor Author

@cdancy Sure. I can send you a PR.

@cdancy
Copy link
Owner

cdancy commented May 3, 2018

@Dhivyaa21 check out this PR and give things a go locally and let me know how you fare. We amend the existing create method to take an optional parameter which, if not null, gets injected into the path. This requires some knowledge of jclouds which is why I went ahead and put the initial impl in place. Feel free to build on top of it as needed. Some live/integ tests will need to be coded as well.

#11

@Dhivyaa21
Copy link
Contributor Author

Dhivyaa21 commented May 3, 2018

@cdancy This looks good. I am adding tests to this change. Meanwhile, a quick question. Do you think its a good idea to use this OPTIONAL_FOLDER_PATH_PARAM for all the job APIs? i am not sure if the other job APIs were designed to access jobs in a folder.

Right now we squeeze in the path to job in the {name} path parameter of other APIs. It works fine. It was just the create API that did not have a way to create the job in a folder. Hence, I created this issue.

Example -
Say I want to disable a job in the following path

"/job/folder/job/testJob"

Disable job api is

@Named("jobs:disable")
@Path("/job/{name}/disable")
@Fallback(Fallbacks.FalseOnNotFoundOr404.class)
@Consumes(MediaType.TEXT_HTML)
@POST
boolean disable(@PathParam("name") String jobName);

To disable the job , I'll have to call api().disable("folder/job/testJob") and not api().disable("testJob").

@cdancy
Copy link
Owner

cdancy commented May 3, 2018

@Dhivyaa21 I would say that any endpoint that can take an optional folder parameter you can put together a PR to wire all of them up. As there are a few please put each endpoint change into its own commit for easier viewing/reviewing on my end.

@martinda
Copy link
Collaborator

martinda commented May 4, 2018

Great idea. I need this too. Thanks @Dhivyaa21 and @cdancy

@cdancy
Copy link
Owner

cdancy commented May 14, 2018

Functionality merged per #20

@cdancy cdancy closed this as completed May 14, 2018
@cdancy cdancy modified the milestones: v0.0.7, v0.0.10 May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants