-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add a new function which creates a job in a folder #610
Conversation
Welcome @wxharry! It looks like this is your first PR to jenkins-zh/jenkins-cli 🎉 |
Codecov Report
@@ Coverage Diff @@
## master #610 +/- ##
=======================================
Coverage 37.98% 37.98%
=======================================
Files 13 13
Lines 416 416
=======================================
Hits 158 158
Misses 246 246
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
client/job.go
Outdated
_, err = q.GetJob(path) | ||
// create folder if not exist | ||
if err != nil { | ||
createFolderPayload := CreateJobPayload{ | ||
Name: path, | ||
Mode: "com.cloudbees.hudson.plugins.folder.Folder", | ||
From: jobPayload.From, | ||
} | ||
err = q.Create(createFolderPayload) | ||
if err != nil { | ||
return | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer don't check and create the folder here. Users can check if the folder exists before calling this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is quite similar to https://github.com/jenkins-zh/jenkins-cli/pull/610/files#diff-e829a497145e43bd7519ccab0bc1d6d68e11dc969faeec623b564216d3b1d13eR358.
Please consider reusing it. Such as, you can refactor the function Create
to:
func (q *JobClient) Create(jobPayload CreateJobPayload) (err error) {
return CreateJobInFolder(jobPayload, "/")
}
Make sure that you've checked the boxes below before you submit PR:
Always
For the bug fixes or features only