Skip to content

Commit

Permalink
Fix artifact download url construction (#750)
Browse files Browse the repository at this point in the history
Resolves #660
  • Loading branch information
sikmir authored Feb 8, 2023
1 parent c604484 commit f6e3b54
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/cmd/job_artifact_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
appCfg "github.com/jenkins-zh/jenkins-cli/app/config"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"net/http"
"net/url"
"path/filepath"
"strconv"
"strings"

"github.com/jenkins-zh/jenkins-cli/app/helper"

Expand Down Expand Up @@ -80,11 +82,12 @@ var jobArtifactDownloadCmd = &cobra.Command{
},
}

func (j *JobArtifactDownloadOption) download(url, fileName string) (err error) {
func (j *JobArtifactDownloadOption) download(artifactURL, fileName string) (err error) {
jenkinsURL, _ := url.Parse(j.Jenkins.URL)
downloader := httpdownloader.HTTPDownloader{
RoundTripper: j.RoundTripper,
TargetFilePath: fileName,
URL: fmt.Sprintf("%s%s", j.Jenkins.URL, url),
URL: fmt.Sprintf("%s%s", j.Jenkins.URL, strings.TrimPrefix(artifactURL, jenkinsURL.Path)),
UserName: j.Jenkins.UserName,
Password: j.Jenkins.Token,
Proxy: j.Jenkins.Proxy,
Expand Down

0 comments on commit f6e3b54

Please sign in to comment.