/
plugin_create.go
50 lines (40 loc) · 1.3 KB
/
plugin_create.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cmd
import (
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"os"
"github.com/jenkins-zh/jenkins-cli/util"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/spf13/cobra"
)
// PluginCreateOptions for the plugin create command
type PluginCreateOptions struct {
common.Option
DebugOutput bool
}
var pluginCreateOptions PluginCreateOptions
func init() {
pluginCmd.AddCommand(pluginCreateCmd)
pluginCreateCmd.Flags().BoolVar(&pluginCreateOptions.DebugOutput, "debug-output", false,
i18n.T("If you want the maven output the debug info"))
}
var pluginCreateCmd = &cobra.Command{
Use: "create",
Short: i18n.T("Create a plugin project from the archetypes"),
Long: i18n.T(`Create a plugin project from the archetypes
Plugin tutorial is here https://jenkins.io/doc/developer/tutorial/`),
RunE: func(cmd *cobra.Command, _ []string) (err error) {
binary, err := util.LookPath("mvn", pluginCreateOptions.LookPathContext)
if err == nil {
env := os.Environ()
mvnArgs := []string{"mvn", "archetype:generate", "-U", `-Dfilter=io.jenkins.archetypes:`}
if pluginCreateOptions.DebugOutput {
mvnArgs = append(mvnArgs, "-X")
}
err = util.Exec(binary, mvnArgs, env, pluginCreateOptions.SystemCallExec)
}
return
},
Annotations: map[string]string{
common.Since: "v0.0.23",
},
}