MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / viewRun

Function viewRun

pkg/cmd/buildinformation/view/view.go:78–174  ·  view source on GitHub ↗
(opts *ViewOptions, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

76}
77
78func viewRun(opts *ViewOptions, cmd *cobra.Command) error {
79 buildInfo, err := buildinformation.GetById(opts.Client, opts.Client.GetSpaceID(), opts.idOrName)
80 if err != nil {
81 return err
82 }
83
84 return output.PrintResource(buildInfo, cmd, output.Mappers[*buildinformation.BuildInformation]{
85 Json: func(b *buildinformation.BuildInformation) any {
86 buildInfo := shared.BuildInfoAsJson{
87 Id: b.GetID(),
88 PackageId: b.PackageID,
89 Version: b.Version,
90 Branch: b.Branch,
91 BuildEnvironment: b.BuildEnvironment,
92 VcsCommitNumber: b.VcsCommitNumber,
93 VcsType: b.VcsType,
94 VcsRoot: b.VcsRoot,
95 }
96
97 if len(b.Commits) > 0 {
98 for _, c := range b.Commits {
99 buildInfo.Commits = append(buildInfo.Commits, &shared.CommitAsJson{Id: c.ID, Comment: c.Comment})
100 }
101 }
102
103 if len(b.WorkItems) > 0 {
104 for _, w := range b.WorkItems {
105 buildInfo.WorkItems = append(buildInfo.WorkItems, &shared.WorkItemAsJson{Id: w.ID, Source: w.Source, Description: w.Description})
106 }
107 }
108
109 return buildInfo
110 },
111 Table: output.TableDefinition[*buildinformation.BuildInformation]{
112 Header: []string{
113 "PACKAGE ID",
114 "VERSION",
115 "ENVIRONMENT",
116 "BUILD NO",
117 "BRANCH",
118 "COMMITS",
119 "WORKITEMS"},
120 Row: func(b *buildinformation.BuildInformation) []string {
121 return []string{
122 output.Bold(b.PackageID),
123 b.Version,
124 b.BuildEnvironment,
125 b.BuildNumber,
126 b.Branch,
127 strconv.Itoa(len(b.Commits)),
128 strconv.Itoa(len(b.WorkItems))}
129 },
130 },
131 Basic: func(b *buildinformation.BuildInformation) string {
132 var s strings.Builder
133
134 s.WriteString(fmt.Sprintf("%s %s %s\n", output.Bold(b.PackageID), b.Version, output.Dimf("(%s)", b.GetID())))
135

Callers 1

NewCmdViewFunction · 0.70

Calls 6

PrintResourceFunction · 0.92
BoldFunction · 0.92
DimfFunction · 0.92
DimFunction · 0.92
BlueFunction · 0.92
GenerateWebURLFunction · 0.92

Tested by

no test coverage detected