diff --git a/command/push.go b/command/push.go index 9cb9e6b67..6ba27bada 100644 --- a/command/push.go +++ b/command/push.go @@ -38,6 +38,7 @@ func (c *PushCommand) Run(args []string) int { f := flag.NewFlagSet("push", flag.ContinueOnError) f.Usage = func() { c.Ui.Error(c.Help()) } f.StringVar(&token, "token", "", "token") + f.StringVar(&message, "m", "", "message") f.StringVar(&message, "message", "", "message") if err := f.Parse(args); err != nil { return 1 @@ -149,6 +150,13 @@ func (c *PushCommand) Run(args []string) int { uploadOpts.Builds[b.Name] = info } + // Add the upload metadata + metadata := make(map[string]interface{}) + if message != "" { + metadata["message"] = message + } + uploadOpts.Metadata = metadata + // Warn about builds not having post-processors. var badBuilds []string for name, b := range uploadOpts.Builds { @@ -224,10 +232,10 @@ Usage: packer push [options] TEMPLATE Options: - -message= A message to identify the purpose or changes in this - Packer template much like a VCS commit message + -m, -message= A message to identify the purpose or changes in this + Packer template much like a VCS commit message - -token= The access token to use to when uploading + -token= The access token to use to when uploading ` return strings.TrimSpace(helpText) @@ -279,7 +287,7 @@ func (c *PushCommand) upload( // Start the upload doneCh, errCh := make(chan struct{}), make(chan error) go func() { - err := c.client.UploadBuildConfigVersion(&version, r, r.Size) + err := c.client.UploadBuildConfigVersion(&version, opts.Metadata, r, r.Size) if err != nil { errCh <- err return @@ -292,9 +300,10 @@ func (c *PushCommand) upload( } type uploadOpts struct { - URL string - Slug string - Builds map[string]*uploadBuildInfo + URL string + Slug string + Builds map[string]*uploadBuildInfo + Metadata map[string]interface{} } type uploadBuildInfo struct { diff --git a/website/source/docs/command-line/push.html.markdown b/website/source/docs/command-line/push.html.markdown index bf344aadc..be4040527 100644 --- a/website/source/docs/command-line/push.html.markdown +++ b/website/source/docs/command-line/push.html.markdown @@ -25,6 +25,10 @@ must be completed within the template. ## Options +* `-message` - A message to identify the purpose or changes in this Packer + template much like a VCS commit message. This message will be passed to the + Packer build service. This option is also available as a short option `-m`. + * `-token` - An access token for authenticating the push to the Packer build service such as Atlas. This can also be specified within the push configuration in the template. @@ -34,7 +38,7 @@ must be completed within the template. Push a Packer template: ```shell -$ packer push template.json +$ packer push -m "Updating the apache version" template.json ``` Push a Packer template with a custom token: