Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new feature to create yaml including jenkins core and plugins and give users a choice to choose #620

Merged
merged 42 commits into from
Jun 15, 2022
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5bd6826
add -tail to job log
jxr98 Jul 3, 2021
6134402
Update job_log.go
jxr98 Jul 17, 2021
cc2f86d
change job log back
jxr98 Jul 18, 2021
2e4aedf
Update go.mod
jxr98 Aug 12, 2021
5368e1a
Update go.mod
jxr98 Aug 15, 2021
34e3bc3
ddd
jxr98 Aug 16, 2021
203bc5a
ss
jxr98 Aug 16, 2021
e6291be
ddd
jxr98 Aug 18, 2021
637afcd
Update go.mod
jxr98 Aug 18, 2021
ca54935
Update go.sum
jxr98 Aug 18, 2021
0e6cff3
Update go.sum
jxr98 Aug 19, 2021
2831065
dsss
jxr98 Aug 20, 2021
b776b58
sss
jxr98 Aug 22, 2021
228a503
sss
jxr98 Aug 22, 2021
408e193
update
jxr98 Aug 22, 2021
b893960
update create_yaml
jxr98 Aug 22, 2021
ca7c442
add support to select when generate yaml
jxr98 Aug 25, 2021
212ec5a
complete create yaml
jxr98 Aug 26, 2021
aeeaadc
change the files back
jxr98 Aug 26, 2021
dceb93d
Update center_list.go
jxr98 Aug 26, 2021
4fd5e5f
Update center_list.go
jxr98 Aug 26, 2021
32d6bda
Create docker_run.go
jxr98 Aug 3, 2021
be44073
Update docker_run.go
jxr98 Aug 3, 2021
8a39635
Update docker_run.go
jxr98 Aug 7, 2021
a70db0e
Update docker_run.go
jxr98 Aug 8, 2021
684bfd7
Update docker_run.go
jxr98 Aug 8, 2021
2db6397
Update docker_run.go
jxr98 Aug 8, 2021
e557536
Update go.mod
jxr98 Aug 11, 2021
2e5fd00
Update docker_run.go
jxr98 Aug 12, 2021
d5fe3dc
Update docker_run.go
jxr98 Aug 12, 2021
f8ae56c
Update go.sum
jxr98 Aug 15, 2021
a9f66c6
Update go.sum
jxr98 Aug 15, 2021
066d443
Update go.mod
jxr98 Aug 15, 2021
641d6d8
Bump github.com/linuxsuren/http-downloader from 0.0.29 to 0.0.33 (#622)
dependabot[bot] Aug 30, 2021
6ff2781
Fix computer launch for windows (#635)
yJunS Sep 22, 2021
ed343be
Run release drafter in the GitHub action (#636)
LinuxSuRen Sep 22, 2021
eaf5594
change create yaml to be a complete function which is upgrade labmouse
jxr98 Sep 28, 2021
b6f6acc
sorry - revert last 5 commits cuz I mistakely includes commits from o…
jxr98 Sep 28, 2021
2e4e8d4
update upgrade_labmouse.go
jxr98 Sep 28, 2021
89817bd
modify
jxr98 Sep 28, 2021
ac35eda
correct some lint mistakes and modify go.mod ad go.sum
jxr98 Sep 28, 2021
fa3cb40
Merge branch 'master' into yaml
LinuxSuRen Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dsss
jxr98 committed Sep 12, 2021
commit 2831065aec191b252af55eec4776c3116cc5f3d4
32 changes: 30 additions & 2 deletions app/cmd/create_yaml.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/jenkins-zh/jenkins-cli/client"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)

type YamlOption struct {
@@ -43,16 +44,22 @@ type coreAndPluginOption struct {
}

var coreAndPlugin coreAndPluginOption
var yamlOption YamlOption

func init() {
rootCmd.AddCommand(createYamlCmd)
createYamlCmd.Flags().StringArrayVarP(&coreAndPlugin.filter, "filter", "", []string{}, i18n.T("Filter for the list"))
createYamlCmd.Flags().BoolVarP(&coreAndPlugin.all, "all", "", false, i18n.T("Upgrade jenkins core and all plugins to update"))
createYamlCmd.Flags().BoolVarP(&coreAndPlugin.core, "core", "", false, i18n.T("Only upgrade jenkins core"))
createYamlCmd.Flags().StringVarP(&yamlOption.Bundle.GroupId, "bundle-groupId", "", "io.jenkins.tools.jcli.yaml.demo", i18n.T("GourpId of Bundle in yaml"))
createYamlCmd.Flags().StringVarP(&yamlOption.Bundle.ArtifactId, "bundle-artifactId", "", "jcli yaml demo", i18n.T("ArtifactId of Bundle in yaml"))
createYamlCmd.Flags().StringVarP(&yamlOption.Bundle.Vendor, "bundle-vendor", "", "jenkins-cli", i18n.T("Vendor of Bundle in yaml"))
createYamlCmd.Flags().StringVarP(&yamlOption.Bundle.Title, "bundle-title", "", "jcli create yaml demo", i18n.T("Title of Bundle in yaml"))
createYamlCmd.Flags().StringVarP(&yamlOption.Bundle.Description, "bundle-description", "", "Upgraded jenkins core and plugins in a YAML specification", i18n.T("Description of Bundle in yaml"))
}

var createYamlCmd = &cobra.Command{
Use: "",
Use: "create yaml",
Short: "",
Long: "",
Example: ``,
@@ -87,7 +94,11 @@ func (c *coreAndPluginOption) multipleChoice(cmd *cobra.Command, args []string)
var yamlOption YamlOption
if c.all {
if _, pluginList, err := getLocalJenkinsAndPlugins(); err == nil {
yamlOption.Plugins = make([]Plugin, len(pluginList))
for index, plugin := range pluginList {
if index >= 5 {
break
}
yamlOption.Plugins[index].GroupId, yamlOption.Plugins[index].ArtifactId, yamlOption.Plugins[index].Source.Version, err = getGroupIdAndArtifactId(plugin.ShortName)
if err != nil {
return err
@@ -99,6 +110,7 @@ func (c *coreAndPluginOption) multipleChoice(cmd *cobra.Command, args []string)
yamlOption.War.Source.Version = items[0].Title[8:]
}
}
renderBundle(cmd)
}
return nil
}
@@ -119,7 +131,7 @@ func getGroupIdAndArtifactId(pluginName string) (groupId string, artifactId stri
if err != nil {
return "", "", "", err
}
version, groupId, artifactId = trimToId(pluginName)
version, groupId, artifactId = trimToId(newPluginOption.Version)

return groupId, artifactId, version, nil
}
@@ -132,3 +144,19 @@ func trimToId(content string) (version string, groupId string, artifactId string
artifactId = content[endOfGroupId+1 : startOfVersionNumber]
return version, groupId, artifactId
}

func renderBundle(cmd *cobra.Command) (err error) {
bundle := Bundle{
yamlOption.Bundle.GroupId,
yamlOption.Bundle.ArtifactId,
yamlOption.Bundle.Vendor,
yamlOption.Bundle.Title,
yamlOption.Bundle.Description,
}
d, err := yaml.Marshal(&bundle)
if err != nil {
return err
}
cmd.Printf(string(d))
return nil
}