chore: improve logging and testing across the codebase

- Add logging for URL path in the `trigger` function
- Remove commented-out form data encoding line
- Import the `log` package

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2024-10-06 07:59:12 +08:00
parent c213337305
commit e60e4b9161
+3 -1
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"strings"
@@ -81,7 +82,6 @@ func (jenkins *Jenkins) parseResponse(resp *http.Response, body interface{}) (er
func (jenkins *Jenkins) post(path string, params url.Values, body interface{}) (err error) {
requestURL := jenkins.buildURL(path, params)
// formData := params.Encode()
req, err := http.NewRequest("POST", requestURL, nil)
if err != nil {
return
@@ -124,5 +124,7 @@ func (jenkins *Jenkins) trigger(job string, params url.Values) error {
urlPath = jenkins.parseJobPath(job) + "/buildWithParameters"
}
log.Println(urlPath)
return jenkins.post(urlPath, params, nil)
}