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

CreateView Function doesn't allow creation of a view inside of a folder #318

Open
abrockmeyer-govtact opened this issue Dec 29, 2023 · 1 comment

Comments

@abrockmeyer-govtact
Copy link

The endpoint is always on the main jenkins url.
I would hope to see an implementation where a folder name can be passed in as "test_folder" and the endpoint would be modified to be

if folder {
      endpoint := "jobs/" + folder + "/createView"
}

Or even just passing in "jobs/test_folder/jobs/test_folder2" could do nested folders 2 layers deep. Either would help.

func (j *Jenkins) CreateView(ctx context.Context, name string, viewType string) (*View, error) {
	view := &View{Jenkins: j, Raw: new(ViewResponse), Base: "/view/" + name}
	endpoint := "/createView"
	data := map[string]string{
		"name":   name,
		"mode":   viewType,
		"Submit": "OK",
		"json": makeJson(map[string]string{
			"name": name,
			"mode": viewType,
		}),
	}
	r, err := j.Requester.Post(ctx, endpoint, nil, view.Raw, data)

	if err != nil {
		return nil, err
	}

	if r.StatusCode == 200 {
		return j.GetView(ctx, name)
	}
	return nil, errors.New(strconv.Itoa(r.StatusCode))
}
@abrockmeyer-govtact
Copy link
Author

abrockmeyer-govtact commented Dec 29, 2023

It looks like Pull Request #269 takes care of this functionality as well. Albeit it creates a new function CreateViewInFolder as opposed to modifying this section of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant