mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 14:18:42 +00:00
Add logs
command to CLI & update forges supported features docs (#1064)
* Complete forges overview + add `logs` command to CLI * Update 10-overview.md Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
2f5e5b8e2c
commit
d22821afc1
5 changed files with 53 additions and 10 deletions
|
@ -2,8 +2,10 @@ package build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/cli/common"
|
"github.com/woodpecker-ci/woodpecker/cli/common"
|
||||||
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
@ -17,6 +19,35 @@ var buildLogsCmd = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildLogs(c *cli.Context) error {
|
func buildLogs(c *cli.Context) error {
|
||||||
// TODO: add logs command
|
repo := c.Args().First()
|
||||||
return fmt.Errorf("Command temporarily disabled. See https://github.com/woodpecker-ci/woodpecker/issues/383")
|
owner, name, err := internal.ParseRepo(repo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
number, err := strconv.Atoi(c.Args().Get(1))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
job, err := strconv.Atoi(c.Args().Get(2))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := internal.NewClient(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logs, err := client.BuildLogs(owner, name, number, job)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, log := range logs {
|
||||||
|
fmt.Print(log.Output)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
| Feature | [GitHub](github/) | [Gitea](gitea/) | [Gitlab](gitlab/) | [Bitbucket](bitbucket/) | [Bitbucket Server](bitbucket_server/) | [Gogs](gogs/) | [Coding](coding/) |
|
| Feature | [GitHub](github/) | [Gitea](gitea/) | [Gitlab](gitlab/) | [Bitbucket](bitbucket/) | [Bitbucket Server](bitbucket_server/) | [Gogs](gogs/) | [Coding](coding/) |
|
||||||
| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
||||||
| Event: Push | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| Event: Push | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| Event: Tag | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| Event: Tag | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: |
|
||||||
| Event: Pull-Request | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| Event: Pull-Request | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: |
|
||||||
| Event: Deploy | :white_check_mark: | :x: | :x: |
|
| Event: Deploy | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: |
|
||||||
| OAuth | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| OAuth | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
||||||
| [Multi pipeline](/docs/usage/multi-pipeline) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: |
|
| [Multi pipeline](/docs/usage/multi-pipeline) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: |
|
||||||
| [when.path filter](/docs/usage/pipeline-syntax#path) | :white_check_mark: | :white_check_mark:¹ | :white_check_mark: | :x: | :x: | :x: | :x: |
|
| [when.path filter](/docs/usage/pipeline-syntax#path) | :white_check_mark: | :white_check_mark:¹ | :white_check_mark: | :x: | :x: | :x: | :x: |
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package woodpecker
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -22,6 +21,7 @@ const (
|
||||||
pathRepair = "%s/api/repos/%s/%s/repair"
|
pathRepair = "%s/api/repos/%s/%s/repair"
|
||||||
pathBuilds = "%s/api/repos/%s/%s/builds"
|
pathBuilds = "%s/api/repos/%s/%s/builds"
|
||||||
pathBuild = "%s/api/repos/%s/%s/builds/%v"
|
pathBuild = "%s/api/repos/%s/%s/builds/%v"
|
||||||
|
pathLogs = "%s/api/repos/%s/%s/logs/%d/%d"
|
||||||
pathApprove = "%s/api/repos/%s/%s/builds/%d/approve"
|
pathApprove = "%s/api/repos/%s/%s/builds/%d/approve"
|
||||||
pathDecline = "%s/api/repos/%s/%s/builds/%d/decline"
|
pathDecline = "%s/api/repos/%s/%s/builds/%d/decline"
|
||||||
pathJob = "%s/api/repos/%s/%s/builds/%d/%d"
|
pathJob = "%s/api/repos/%s/%s/builds/%d/%d"
|
||||||
|
@ -258,8 +258,11 @@ func (c *client) BuildKill(owner, name string, num int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildLogs returns the build logs for the specified job.
|
// BuildLogs returns the build logs for the specified job.
|
||||||
func (c *client) BuildLogs(owner, name string, num, job int) (io.ReadCloser, error) {
|
func (c *client) BuildLogs(owner, name string, num, job int) ([]*Logs, error) {
|
||||||
return nil, errors.New("Method not implemented")
|
uri := fmt.Sprintf(pathLogs, c.addr, owner, name, num, job)
|
||||||
|
var out []*Logs
|
||||||
|
err := c.get(uri, &out)
|
||||||
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy triggers a deployment for an existing build using the
|
// Deploy triggers a deployment for an existing build using the
|
||||||
|
|
|
@ -88,6 +88,9 @@ type Client interface {
|
||||||
// BuildKill force kills the running build.
|
// BuildKill force kills the running build.
|
||||||
BuildKill(string, string, int) error
|
BuildKill(string, string, int) error
|
||||||
|
|
||||||
|
// BuildLogs returns the logs for the given build
|
||||||
|
BuildLogs(string, string, int, int) ([]*Logs, error)
|
||||||
|
|
||||||
// Deploy triggers a deployment for an existing build using the specified
|
// Deploy triggers a deployment for an existing build using the specified
|
||||||
// target environment.
|
// target environment.
|
||||||
Deploy(string, string, int, string, map[string]string) (*Build, error)
|
Deploy(string, string, int, string, map[string]string) (*Build, error)
|
||||||
|
|
|
@ -157,4 +157,10 @@ type (
|
||||||
LogLevel struct {
|
LogLevel struct {
|
||||||
Level string `json:"log-level"`
|
Level string `json:"log-level"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logs is the JSON data for a logs response
|
||||||
|
Logs struct {
|
||||||
|
Proc string `json:"proc"`
|
||||||
|
Output string `json:"out"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue