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

Add a new function which creates a job in a folder #610

Merged
merged 2 commits into from
Aug 15, 2021

Conversation

wxharry
Copy link
Contributor

@wxharry wxharry commented Aug 12, 2021

Make sure that you've checked the boxes below before you submit PR:

Always

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Written well with PR title, we generate the release notes base on that

For the bug fixes or features only

  • Quality Gate Passed. Change this URL to your PR.
  • The coverage is xxx on the new lines
  • I've tested it by manual in the following platform
    • MacOS
    • Linux
    • Windows
  • Unit Test covered
  • e2e Test covered

@linuxsuren-bot
Copy link

Welcome @wxharry! It looks like this is your first PR to jenkins-zh/jenkins-cli 🎉

@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2021

Codecov Report

Merging #610 (eb6cc4e) into master (b2914bd) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #610   +/-   ##
=======================================
  Coverage   37.98%   37.98%           
=======================================
  Files          13       13           
  Lines         416      416           
=======================================
  Hits          158      158           
  Misses        246      246           
  Partials       12       12           
Flag Coverage Δ
unittests 37.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2914bd...eb6cc4e. Read the comment docs.

client/job.go Outdated
Comment on lines 380 to 392
_, 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
}
}
Copy link
Member

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.

Copy link
Member

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, "/")
}

@wxharry wxharry changed the title Add a new function which create a job in a folder Add a new function which creates a job in a folder Aug 13, 2021
@LinuxSuRen LinuxSuRen merged commit 2ca7829 into jenkins-zh:master Aug 15, 2021
jxr98 pushed a commit to jxr98/jenkins-cli that referenced this pull request Aug 29, 2021
jxr98 pushed a commit to jxr98/jenkins-cli that referenced this pull request Sep 4, 2021
@LinuxSuRen LinuxSuRen added the enhancement New feature or request label Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants