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

Function NewCmdCreate

pkg/cmd/release/create/create.go:150–202  ·  view source on GitHub ↗
(f factory.Factory)

Source from the content-addressed store, hash-verified

148}
149
150func NewCmdCreate(f factory.Factory) *cobra.Command {
151 createFlags := NewCreateFlags()
152
153 cmd := &cobra.Command{
154 Use: "create",
155 Short: "Create a release",
156 Long: "Create a release in Octopus Deploy",
157 Example: heredoc.Docf(`
158 %[1]s release create --project MyProject --channel Beta --version 1.2.3
159 %[1]s release create -p MyProject -c Beta -v 1.2.3
160 %[1]s release create -p MyProject -c default --package "utils:1.2.3" --package "utils:InstallOnly:5.6.7"
161 %[1]s release create -p MyProject -c Beta --no-prompt
162 `, constants.ExecutableName),
163 RunE: func(cmd *cobra.Command, args []string) error { return createRun(cmd, f, createFlags) },
164 }
165
166 // project is required in automation mode, other options are not. Nothing is required in interactive mode because we prompt for everything
167 flags := cmd.Flags()
168 flags.StringVarP(&createFlags.Project.Value, createFlags.Project.Name, "p", "", "Name or ID of the project to create the release in")
169 flags.StringVarP(&createFlags.Channel.Value, createFlags.Channel.Name, "c", "", "Name or ID of the channel to use")
170 flags.StringVarP(&createFlags.GitRef.Value, createFlags.GitRef.Name, "r", "", "Git Reference e.g. refs/heads/main. Only relevant for config-as-code projects")
171 flags.StringVarP(&createFlags.GitCommit.Value, createFlags.GitCommit.Name, "", "", "Git Commit Hash; Specify this in addition to Git Reference if you want to reference a commit other than the latest for that branch/tag.")
172 flags.StringVarP(&createFlags.PackageVersion.Value, createFlags.PackageVersion.Name, "", "", "Default version to use for all Packages")
173 flags.StringVar(&createFlags.ReleaseNotes.Value, createFlags.ReleaseNotes.Name, "", "Release notes to attach")
174 flags.StringVarP(&createFlags.ReleaseNotesFile.Value, createFlags.ReleaseNotesFile.Name, "", "", "Release notes to attach (from file)")
175 flags.StringVarP(&createFlags.Version.Value, createFlags.Version.Name, "v", "", "Override the Release Version")
176 flags.BoolVarP(&createFlags.IgnoreExisting.Value, createFlags.IgnoreExisting.Name, "x", false, "If a release with the same version exists, do nothing instead of failing.")
177 flags.BoolVarP(&createFlags.IgnoreChannelRules.Value, createFlags.IgnoreChannelRules.Name, "", false, "Allow creation of a release where channel rules would otherwise prevent it.")
178 flags.StringArrayVarP(&createFlags.PackageVersionSpec.Value, createFlags.PackageVersionSpec.Name, "", []string{}, "Version specification for a specific package.\nFormat as {package}:{version}, {step}:{version} or {package-ref-name}:{packageOrStep}:{version}\nYou may specify this multiple times")
179 flags.StringArrayVarP(&createFlags.GitResourceRefsSpec.Value, createFlags.GitResourceRefsSpec.Name, "", []string{}, "Git reference for a specific Git resource.\nFormat as {step}:{git-ref}, {step}:{git-resource-name}:{git-ref}\nYou may specify this multiple times")
180 flags.StringArrayVarP(&createFlags.CustomFields.Value, createFlags.CustomFields.Name, "", []string{}, "Custom field value to set on the release.\nFormat as {name}:{value}. You may specify multiple times")
181
182 // we want the help text to display in the above order, rather than alphabetical
183 flags.SortFlags = false
184
185 // flags aliases for compat with old .NET CLI
186 flagAliases := make(map[string][]string, 10)
187 util.AddFlagAliasesString(flags, FlagGitRef, flagAliases, FlagAliasGitRefRef, FlagAliasGitRefLegacy)
188 util.AddFlagAliasesString(flags, FlagGitCommit, flagAliases, FlagAliasGitCommitLegacy)
189 util.AddFlagAliasesString(flags, FlagPackageVersion, flagAliases, FlagAliasDefaultPackageVersion, FlagAliasPackageVersionLegacy, FlagAliasDefaultPackageVersionLegacy)
190 util.AddFlagAliasesString(flags, FlagReleaseNotes, flagAliases, FlagAliasReleaseNotesLegacy)
191 util.AddFlagAliasesString(flags, FlagReleaseNotesFile, flagAliases, FlagAliasReleaseNotesFileLegacy, FlagAliasReleaseNoteFileLegacy)
192 util.AddFlagAliasesString(flags, FlagVersion, flagAliases, FlagAliasReleaseNumberLegacy)
193 util.AddFlagAliasesBool(flags, FlagIgnoreExisting, flagAliases, FlagAliasIgnoreExistingLegacy)
194 util.AddFlagAliasesBool(flags, FlagIgnoreChannelRules, flagAliases, FlagAliasIgnoreChannelRulesLegacy)
195
196 cmd.PreRunE = func(cmd *cobra.Command, args []string) error {
197 util.ApplyFlagAliases(cmd.Flags(), flagAliases)
198 return nil
199 }
200
201 return cmd
202}
203
204func createRun(cmd *cobra.Command, f factory.Factory, flags *CreateFlags) error {
205 outputFormat, err := cmd.Flags().GetString(constants.FlagOutputFormat)

Callers

nothing calls this directly

Calls 5

AddFlagAliasesStringFunction · 0.92
AddFlagAliasesBoolFunction · 0.92
ApplyFlagAliasesFunction · 0.92
NewCreateFlagsFunction · 0.70
createRunFunction · 0.70

Tested by

no test coverage detected