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

fix: artifact cannot work with some plugins #804

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/cmd/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package common

import (
"bytes"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"reflect"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/computer_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/computer_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-client/pkg/computer"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"

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

Expand Down
2 changes: 1 addition & 1 deletion app/cmd/config_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"fmt"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/credential_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"net/http"

"github.com/jenkins-zh/jenkins-cli/client"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"strconv"

"github.com/jenkins-zh/jenkins-cli/client"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/jenkins-zh/jenkins-cli/client"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job_history.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"net/http"

"github.com/jenkins-zh/jenkins-cli/app/i18n"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"encoding/json"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"net/http"

"github.com/jenkins-zh/jenkins-cli/client"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/jenkins-zh/jenkins-cli/client"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion app/cmd/job_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"

"github.com/jenkins-zh/jenkins-cli/client"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/plugin_formula.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/jenkins-zh/jenkins-cli/client"
jenkinsFormula "github.com/jenkins-zh/jenkins-formulas/pkg/common"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/plugin_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/jenkins-zh/jenkins-cli/client"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"github.com/spf13/cobra"
"net/http"
)
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/plugin_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"bytes"
"fmt"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"net/http"
"strings"

Expand Down
2 changes: 1 addition & 1 deletion app/cmd/queue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/jenkins-zh/jenkins-cli/app/i18n"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"net/http"

"github.com/jenkins-zh/jenkins-cli/client"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/jenkins-zh/jenkins-cli/app/helper"
cobra_ext "github.com/linuxsuren/cobra-extension"
cobra_ext "github.com/linuxsuren/cobra-extension/pkg"
"net/http"

"github.com/jenkins-zh/jenkins-cli/client"
Expand Down
29 changes: 29 additions & 0 deletions client/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
Size int64
}

type JobWithArtifacts struct {

Check failure on line 17 in client/artifacts.go

View workflow job for this annotation

GitHub Actions / Lint

exported type JobWithArtifacts should have comment or be unexported
Artifacts []JobArtifact `json:"artifacts"`
}

func (j JobWithArtifacts) GetArtifacts() (artifacts []Artifact) {

Check failure on line 21 in client/artifacts.go

View workflow job for this annotation

GitHub Actions / Lint

exported method JobWithArtifacts.GetArtifacts should have comment or be unexported
for _, a := range j.Artifacts {
artifacts = append(artifacts, Artifact{
ID: a.FileName,
Name: a.FileName,
Path: a.RelativePath,
})
}
return
}

type JobArtifact struct {

Check failure on line 32 in client/artifacts.go

View workflow job for this annotation

GitHub Actions / Lint

exported type JobArtifact should have comment or be unexported
RelativePath string `json:"relativePath"`
FileName string `json:"fileName"`
}

// ArtifactClient is client for getting the artifacts
type ArtifactClient struct {
JenkinsCore
Expand All @@ -23,11 +43,20 @@
func (q *ArtifactClient) List(jobName string, buildID int) (artifacts []Artifact, err error) {
path := ParseJobPath(jobName)
var api string
var oldAPI string
if buildID < 1 {
api = fmt.Sprintf("%s/lastBuild/wfapi/artifacts", path)
oldAPI = fmt.Sprintf("%s/lastBuild/api/json", path)
} else {
api = fmt.Sprintf("%s/%d/wfapi/artifacts", path, buildID)
oldAPI = fmt.Sprintf("%s/%d/api/json", path, buildID)
}
err = q.RequestWithData(http.MethodGet, api, nil, nil, 200, &artifacts)
if err != nil {
job := JobWithArtifacts{}
if err = q.RequestWithData(http.MethodGet, oldAPI, nil, nil, 200, &job); err == nil {
artifacts = job.GetArtifacts()
}
}
return
}
70 changes: 62 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
module github.com/jenkins-zh/jenkins-cli

go 1.16
go 1.20

require (
github.com/AlecAivazis/survey/v2 v2.3.2
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
github.com/Pallinder/go-randomdata v1.2.0
github.com/atotto/clipboard v0.1.4
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1
github.com/containerd/containerd v1.5.5 // indirect
github.com/docker/docker v20.10.8+incompatible
github.com/docker/go-connections v0.4.0
github.com/golang/mock v1.6.0
github.com/google/go-github/v29 v29.0.3
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/go-version v1.2.1
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec
github.com/jedib0t/go-pretty/v6 v6.2.4
github.com/jenkins-zh/jenkins-client v0.0.13
github.com/jenkins-zh/jenkins-client v0.0.14
github.com/jenkins-zh/jenkins-formulas v0.0.5
github.com/linuxsuren/cobra-extension v0.0.16
github.com/linuxsuren/go-cli-alias v0.0.6
github.com/linuxsuren/go-cli-plugin v0.0.4
github.com/linuxsuren/go-cli-alias v0.0.10
github.com/linuxsuren/go-cli-plugin v0.0.5
github.com/linuxsuren/http-downloader v0.0.85
github.com/magiconair/properties v1.8.5
github.com/mitchellh/go-homedir v1.1.0
github.com/moby/moby v20.10.8+incompatible
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.18.1
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
Expand All @@ -40,3 +36,61 @@ require (
gopkg.in/yaml.v2 v2.4.0
moul.io/http2curl v1.0.0
)

require (
github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/containerd/containerd v1.5.5 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/creack/pty v1.1.17 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/godbus/dbus v4.1.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/progressbar/v3 v3.13.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
google.golang.org/grpc v1.33.2 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading