未验证 提交 2ac6d95d 编写于 作者: LinuxSuRen's avatar LinuxSuRen 提交者: GitHub

WIP: Add support to build a plugin project (#355)

* Add support to build a plugin project

* Improve the pull request template

* Add support download a formula jenkins.war
上级 1780ddfd
......@@ -9,7 +9,10 @@
- [ ] [Quality Gate Passed](https://sonarcloud.io/dashboard?id=jenkins-zh_jenkins-cli). Change this URL to your PR.
- [ ] The coverage is xxx on the new lines
- [ ] I've tested it locally
- [ ] I've tested it by manual in the following platform
- [ ] MacOS
- [ ] Linux
- [ ] Windows
<!--
Put an `x` into the [ ] to show you have filled the information
......
......@@ -42,12 +42,17 @@ func init() {
i18n.T("If you want to show the download progress"))
centerDownloadCmd.Flags().StringVarP(&centerDownloadOption.Output, "output", "o", "",
i18n.T("The file of output"))
centerDownloadCmd.Flags().StringVarP(&centerDownloadOption.Formula, "formula", "", "",
i18n.T("The formula of jenkins.war, only support zh currently"))
}
var centerDownloadCmd = &cobra.Command{
Use: "download",
Short: i18n.T("Download Jenkins"),
Long: i18n.T(`Download Jenkins from a mirror site. You can get more mirror sites from https://jenkins-zh.cn/tutorial/management/mirror/`),
Short: i18n.T("Download jenkins.war"),
Long: i18n.T(`Download jenkins.war from a mirror site.
You can get more mirror sites from https://jenkins-zh.cn/tutorial/management/mirror/
If you want to download different formulas of jenkins.war, please visit the following project
https://github.com/jenkins-zh/docker-zh`),
RunE: func(cmd *cobra.Command, _ []string) error {
return centerDownloadOption.DownloadJenkins()
},
......
package cmd
import (
"os"
"github.com/jenkins-zh/jenkins-cli/util"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/spf13/cobra"
)
// PluginBuildOptions for the plugin build command
type PluginBuildOptions struct {
CommonOption
DebugOutput bool
}
var pluginBuildOptions PluginBuildOptions
func init() {
pluginCmd.AddCommand(pluginBuildCmd)
pluginBuildCmd.Flags().BoolVar(&pluginBuildOptions.DebugOutput, "debug-output", false,
i18n.T("If you want the maven output the debug info"))
}
var pluginBuildCmd = &cobra.Command{
Use: "build",
Short: i18n.T("Build the Jenkins plugin project"),
Long: i18n.T(`Build the Jenkins plugin project
The default behaviour is "mvn clean package -DskipTests -Dmaven.test.skip"`),
RunE: func(cmd *cobra.Command, _ []string) (err error) {
binary, err := util.LookPath("mvn", pluginBuildOptions.LookPathContext)
if err == nil {
env := os.Environ()
mvnArgs := []string{"mvn", "clean", "package", "-DskipTests", "-Dmaven.test.skip"}
if pluginBuildOptions.DebugOutput {
mvnArgs = append(mvnArgs, "-X")
}
err = util.Exec(binary, mvnArgs, env, pluginBuildOptions.SystemCallExec)
}
return
},
Annotations: map[string]string{
since: "v0.0.27",
},
}
......@@ -134,8 +134,8 @@ func (u *UpdateCenterManager) GetJenkinsWarURL() (warURL string) {
version = "latest"
}
if u.Formula == "zh" {
warURL = fmt.Sprintf("https://dl.bintray.com/jenkins-zh/generic/jenkins/%s/jenkins-zh.war", version)
if u.Formula != "" {
warURL = fmt.Sprintf("https://dl.bintray.com/jenkins-zh/generic/jenkins/%s/jenkins-%s.war", version, u.Formula)
} else if u.LTS {
warURL = fmt.Sprintf("%s/war-stable/%s/jenkins.war", strings.TrimRight(u.MirrorSite, "/"), version)
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册