Skip to content

Commit

Permalink
Build search in branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Apr 1, 2021
1 parent a71796c commit a1eafc2
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions cmd/buildSearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ You can change the display options using additional flags - see 'ontrack-cli bui
if err != nil {
return err
}
branch = NormalizeBranchName(branch)

// Project vs. branch search
if branch == "" {
Expand Down Expand Up @@ -131,8 +132,55 @@ func projectSearch(cmd *cobra.Command, project string) error {
}

func branchSearch(cmd *cobra.Command, project string, branch string) error {
// TODO
return nil
// Query
query := `
query BuildBranchSearch(
$project: String!,
$branch: String!,
$buildBranchFilter: StandardBuildFilter!
) {
builds(
project: $project,
branch: $branch,
buildBranchFilter: $buildBranchFilter
) {
name
branch {
name
}
}
}
`

// Search form
form := make(map[string]interface{})
if err := fillFormWithProperty(cmd, &form, "withProperty", "withPropertyValue"); err != nil {
return err
}
if err := fillFormWithCount(cmd, &form, "count"); err != nil {
return err
}

// Gets the configuration
cfg, err := config.GetSelectedConfiguration()
if err != nil {
return err
}

// Result data
var data buildList

// Call
if err := client.GraphQLCall(cfg, query, map[string]interface{}{
"project": project,
"branch": branch,
"buildBranchFilter": form,
}, &data); err != nil {
return err
}

// Displaying the data
return displayBuilds(cmd, &data)
}

func displayBuilds(cmd *cobra.Command, data *buildList) error {
Expand Down

0 comments on commit a1eafc2

Please sign in to comment.