cmd

package
v0.0.31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2020 License: MIT Imports: 55 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DocTypeMarkdown represents markdown type of doc
	DocTypeMarkdown string = "Markdown"
	// DocTypeManPage represents man page type of doc
	DocTypeManPage string = "ManPage"
)
View Source
const (
	// UTF8 is the chart set name
	UTF8 = "UTF-8"
	// GB18030 is the chart set name
	GB18030 = "GB18030"
)
View Source
const (
	// AgentJNLP is the agent type of jnlp
	AgentJNLP = "jnlp"
)
View Source
const (
	// SafeShutdown the text about shutdown safely
	SafeShutdown = "Puts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins"
)

Variables

View Source
var ShellTypes = []string{
	"zsh", "bash", "powerShell",
}

ShellTypes contains all types of shell

Functions

func ConvertByte2String added in v0.0.31

func ConvertByte2String(byte []byte, charset string) string

ConvertByte2String convert byte to string

func Execute

func Execute()

Execute will execute the command

func GenerateSampleConfig added in v0.0.29

func GenerateSampleConfig() ([]byte, error)

GenerateSampleConfig returns a sample config

func GetCategories added in v0.0.22

func GetCategories(jclient *client.JobClient) (
	typeMap map[string]string, types []string, err error)

GetCategories returns the categories of current Jenkins

func GetComputerClient added in v0.0.24

func GetComputerClient(option common.Option) (*client.ComputerClient, *appCfg.JenkinsServer)

GetComputerClient returns the client of computer

func GetConfigFromHome added in v0.0.23

func GetConfigFromHome() (configPath string, homeErr error)

GetConfigFromHome returns the config file path from user home dir

func GetRootCommand added in v0.0.29

func GetRootCommand() *cobra.Command

GetRootCommand returns the root cmd

func NewConfigPluginFetchCmd added in v0.0.28

func NewConfigPluginFetchCmd() (cmd *cobra.Command)

NewConfigPluginFetchCmd create a command for fetching plugin metadata

func NewConfigPluginInstallCmd added in v0.0.28

func NewConfigPluginInstallCmd() (cmd *cobra.Command)

NewConfigPluginInstallCmd create a command for fetching plugin metadata

func NewConfigPluginListCmd added in v0.0.28

func NewConfigPluginListCmd() (cmd *cobra.Command)

NewConfigPluginListCmd create a command for list all jcli plugins

func NewShutdownCmd added in v0.0.29

func NewShutdownCmd(rootOpt *RootOptions) (cmd *cobra.Command)

NewShutdownCmd create the shutdown command

func RenderTemplate added in v0.0.27

func RenderTemplate(filepath string, values map[string]string) (result string, err error)

RenderTemplate render a go template to a temporary file

func ResetJobBuildOption added in v0.0.23

func ResetJobBuildOption()

ResetJobBuildOption give it a clean option struct

func SortPlugins added in v0.0.31

func SortPlugins(plugins []jenkinsFormula.Plugin) []jenkinsFormula.Plugin

SortPlugins sort the plugins by asc

Types

type CASCApplyOption added in v0.0.24

type CASCApplyOption struct {
	RoundTripper http.RoundTripper
}

CASCApplyOption as the options of apply configuration as code

type CASCExportOption added in v0.0.24

type CASCExportOption struct {
	RoundTripper http.RoundTripper
}

CASCExportOption as the options of reload configuration as code

type CASCOpenOption added in v0.0.24

type CASCOpenOption struct {
	ExecContext util.ExecContext

	Browser string
}

CASCOpenOption is the option of casc open cmd

type CASCOptions added in v0.0.24

type CASCOptions struct {
	common.Option
}

CASCOptions is the option of casc

func (*CASCOptions) Check added in v0.0.24

func (o *CASCOptions) Check() (err error)

Check do the health check of casc cmd

type CASCReloadOption added in v0.0.24

type CASCReloadOption struct {
	RoundTripper http.RoundTripper
}

CASCReloadOption as the options of reload configuration as code

type CASCSchemaOption added in v0.0.24

type CASCSchemaOption struct {
	RoundTripper http.RoundTripper
}

CASCSchemaOption as the options of reload configuration as code

type CWPOptions added in v0.0.27

type CWPOptions struct {
	common.Option

	ConfigPath      string
	Version         string
	TmpDir          string
	Environment     string
	BomPath         string
	MvnSettingsFile string

	BatchMode        bool
	Demo             bool
	InstallArtifacts bool

	ShowProgress bool
	MetadataURL  string
	LocalCache   string
	PrintVersion bool

	ValueSet map[string]string
}

CWPOptions is the option of custom-war-packager see also https://github.com/jenkinsci/custom-war-packager

func (*CWPOptions) Download added in v0.0.27

func (o *CWPOptions) Download() (err error)

Download get the latest cwp from server into local

func (*CWPOptions) GetCWPURL added in v0.0.27

func (o *CWPOptions) GetCWPURL(version string) string

GetCWPURL returns the download URL of a specific version cwp

func (*CWPOptions) GetLatest added in v0.0.27

func (o *CWPOptions) GetLatest() (version string, err error)

GetLatest returns the latest of cwp

func (*CWPOptions) Run added in v0.0.27

func (o *CWPOptions) Run(cmd *cobra.Command, args []string) (err error)

Run is the main logic of cwp cmd

type CenterDownloadOption added in v0.0.20

type CenterDownloadOption struct {
	LTS     bool
	Mirror  string
	Version string

	Output       string
	ShowProgress bool

	Formula string

	RoundTripper http.RoundTripper
}

CenterDownloadOption as the options of download command

func (*CenterDownloadOption) DownloadJenkins added in v0.0.24

func (c *CenterDownloadOption) DownloadJenkins() (err error)

DownloadJenkins download the Jenkins

type CenterIdentityOption added in v0.0.24

type CenterIdentityOption struct {
	common.Option
}

CenterIdentityOption option for upgrade Jenkins

type CenterLoginOption added in v0.0.31

type CenterLoginOption struct {
	common.Option
	RoundTripper http.RoundTripper
}

CenterLoginOption option for upgrade Jenkins

type CenterMirrorOption added in v0.0.23

type CenterMirrorOption struct {
	RoundTripper http.RoundTripper

	Enable    bool
	MirrorURL string
}

CenterMirrorOption option for upgrade Jenkins

type CenterOption added in v0.0.18

type CenterOption struct {
	common.WatchOption

	RoundTripper http.RoundTripper
	CenterStatus string
}

CenterOption is the center cmd option

type CenterStartOption added in v0.0.24

type CenterStartOption struct {
	common.Option

	Port                      int
	Context                   string
	SetupWizard               bool
	AdminCanGenerateNewTokens bool
	CleanHome                 bool

	// comes from folder plugin
	ConcurrentIndexing int

	Admin string

	HTTPSEnable      bool
	HTTPSPort        int
	HTTPSCertificate string
	HTTPSPrivateKey  string

	Environments []string
	System       []string

	Download     bool
	Version      string
	LTS          bool
	Formula      string
	RandomWebDir bool

	Mode          string
	Image         string
	ContainerUser string
	DryRun        bool
}

CenterStartOption option for upgrade Jenkins

type CenterUpgradeOption added in v0.0.20

type CenterUpgradeOption struct {
	RoundTripper http.RoundTripper
}

CenterUpgradeOption option for upgrade Jenkins

type CenterWatchOption added in v0.0.19

type CenterWatchOption struct {
	common.WatchOption
	UtilNeedRestart     bool
	UtilInstallComplete bool

	RoundTripper  http.RoundTripper
	CeneterStatus string
}

CenterWatchOption as the options of watch command

type CheckResult added in v0.0.28

type CheckResult struct {
	Name       string
	StatusCode int
	Timeout    bool
}

CheckResult is the result of checking

type CompletionOptions added in v0.0.25

type CompletionOptions struct {
	Type string
}

CompletionOptions is the option of completion command

type ComputerCreateOption added in v0.0.24

type ComputerCreateOption struct {
	common.Option
	common.OutputOption
}

ComputerCreateOption option for config list command

type ComputerDeleteOption added in v0.0.24

type ComputerDeleteOption struct {
	common.Option
}

ComputerDeleteOption option for agent delete command

type ComputerLaunchOption added in v0.0.24

type ComputerLaunchOption struct {
	common.Option

	Type         string
	ShowProgress bool

	/** share info between inner functions */
	ComputerClient *client.ComputerClient
	CurrentJenkins *appCfg.JenkinsServer
	Output         string
}

ComputerLaunchOption option for config list command

func (*ComputerLaunchOption) Check added in v0.0.30

func (o *ComputerLaunchOption) Check() (err error)

Check do the health check of casc cmd

func (*ComputerLaunchOption) Launch added in v0.0.24

func (o *ComputerLaunchOption) Launch(name string) (err error)

Launch start a normal agent

func (*ComputerLaunchOption) LaunchJnlp added in v0.0.24

func (o *ComputerLaunchOption) LaunchJnlp(name string) (err error)

LaunchJnlp start a JNLP agent

type ComputerListOption added in v0.0.24

type ComputerListOption struct {
	common.Option
	common.OutputOption
}

ComputerListOption option for config list command

type ComputerLogOption added in v0.0.24

type ComputerLogOption struct {
	common.Option
}

ComputerLogOption option for config list command

type ConfigAddOptions added in v0.0.10

type ConfigAddOptions struct {
	appCfg.JenkinsServer
}

ConfigAddOptions is the config ad option

type ConfigCleanOption added in v0.0.28

type ConfigCleanOption struct {
	Timeout      int
	CleanTimeout bool

	Logger helper.Printer
}

ConfigCleanOption option for config list command

func (*ConfigCleanOption) Check added in v0.0.28

func (o *ConfigCleanOption) Check(jenkins cfg.JenkinsServer) (result CheckResult)

Check check the target JenkinsServer config make a request to a Jenkins API

func (*ConfigCleanOption) CleanByCondition added in v0.0.28

func (o *ConfigCleanOption) CleanByCondition(resultList []CheckResult) (err error)

CleanByCondition do the clean work by conditions

func (*ConfigCleanOption) Run added in v0.0.28

func (o *ConfigCleanOption) Run(cmd *cobra.Command, args []string) (err error)

Run is the main entry point of command config-clean

type ConfigDataOptions added in v0.0.31

type ConfigDataOptions struct {
	Key   string
	Value string
}

ConfigDataOptions is the config data option

type ConfigEditOption added in v0.0.25

type ConfigEditOption struct {
	common.Option
}

ConfigEditOption is the option for edit config command

type ConfigGenerateOption added in v0.0.18

type ConfigGenerateOption struct {
	common.InteractiveOption
	common.Option
	common.BatchOption

	Copy bool
}

ConfigGenerateOption is the config generate cmd option

func (*ConfigGenerateOption) InteractiveWithConfig added in v0.0.25

func (o *ConfigGenerateOption) InteractiveWithConfig(cmd *cobra.Command, data []byte) (err error)

InteractiveWithConfig be friendly for a newer

type ConfigListOption added in v0.0.23

type ConfigListOption struct {
	common.OutputOption

	Config string
}

ConfigListOption option for config list command

type ConfigOptions added in v0.0.9

type ConfigOptions struct {
	common.Option

	ConfigFileLocation string
	Detail             bool
	Decrypt            bool
}

ConfigOptions is the config cmd option

type ConfigSelectOptions added in v0.0.25

type ConfigSelectOptions struct {
	common.Option
}

ConfigSelectOptions is the option for select a config

type CredentialCreateOption added in v0.0.24

type CredentialCreateOption struct {
	Description string
	ID          string
	Store       string

	Username string
	Password string

	Secret string

	Scope string
	Type  string

	RoundTripper http.RoundTripper
}

CredentialCreateOption option for credential delete command

type CredentialDeleteOption added in v0.0.24

type CredentialDeleteOption struct {
	common.BatchOption

	ID    string
	Store string

	RoundTripper http.RoundTripper
}

CredentialDeleteOption option for credential delete command

type CredentialListOption added in v0.0.24

type CredentialListOption struct {
	common.OutputOption

	Store string

	RoundTripper http.RoundTripper
}

CredentialListOption option for credential list command

type CrumbIssuerOptions

type CrumbIssuerOptions struct {
	RoundTripper http.RoundTripper
}

CrumbIssuerOptions contains the command line options

type DocOption added in v0.0.28

type DocOption struct {
	DocType string
}

DocOption is the option for doc generating

type JobArtifactDownloadOption added in v0.0.21

type JobArtifactDownloadOption struct {
	ID           string
	ShowProgress bool
	DownloadDir  string

	Jenkins      *appCfg.JenkinsServer
	RoundTripper http.RoundTripper
}

JobArtifactDownloadOption is the options of job artifact download command

type JobArtifactOption added in v0.0.21

type JobArtifactOption struct {
	common.OutputOption
	common.Option
}

JobArtifactOption is the options of job artifact command

type JobBuildOption added in v0.0.18

type JobBuildOption struct {
	common.BatchOption
	common.Option
	common.OutputOption

	Param      string
	ParamArray []string

	ParamFilePathArray []string

	Wait     bool
	WaitTime int
	Delay    int
	Cause    string
}

JobBuildOption is the job build option

type JobCreateOption added in v0.0.18

type JobCreateOption struct {
	Copy string
	Type string

	RoundTripper http.RoundTripper
}

JobCreateOption is the job create option

type JobDeleteOption added in v0.0.18

type JobDeleteOption struct {
	common.BatchOption
	common.Option
}

JobDeleteOption is the job delete option

type JobDisableOption added in v0.0.27

type JobDisableOption struct {
	common.BatchOption
	common.Option
}

JobDisableOption is the job delete option

type JobEditOption added in v0.0.23

type JobEditOption struct {
	common.Option

	Filename  string
	Script    string
	URL       string
	Sample    bool
	TrimSpace bool
	// Build flag indicates if trigger the Jenkins job after the action of edit
	Build bool
}

JobEditOption is the option for job create command

type JobEnableOption added in v0.0.27

type JobEnableOption struct {
	common.BatchOption
	common.Option
}

JobEnableOption is the job delete option

type JobHistoryOption added in v0.0.18

type JobHistoryOption struct {
	common.OutputOption

	RoundTripper http.RoundTripper
}

JobHistoryOption is the job history option

type JobInputOption added in v0.0.21

type JobInputOption struct {
	common.BatchOption

	Action string

	RoundTripper http.RoundTripper
}

JobInputOption is the job delete option

type JobLogOption added in v0.0.10

type JobLogOption struct {
	common.WatchOption
	History int

	LogText      string
	LastBuildID  int
	LastBuildURL string

	RoundTripper http.RoundTripper
}

JobLogOption is the job log option

type JobOption added in v0.0.10

type JobOption struct {
	common.OutputOption
}

JobOption is the job cmd option

type JobParamOption added in v0.0.18

type JobParamOption struct {
	common.OutputOption

	Indent bool

	RoundTripper http.RoundTripper
}

JobParamOption is the job param option

type JobSearchOption added in v0.0.10

type JobSearchOption struct {
	common.Option
	common.OutputOption
	Name   string
	Type   string
	Parent string

	Start int
	Limit int
}

JobSearchOption is the options of job search command

func (*JobSearchOption) Check added in v0.0.24

func (o *JobSearchOption) Check() (err error)

Check do the conditions check

type JobStopOption added in v0.0.18

type JobStopOption struct {
	common.BatchOption
	common.Option
}

JobStopOption is the job stop option

type JobTypeOption added in v0.0.18

type JobTypeOption struct {
	common.OutputOption
	common.Option
}

JobTypeOption is the job type cmd option

type MavenMetadata added in v0.0.27

type MavenMetadata struct {
	XMLName    xml.Name        `xml:"metadata"`
	Versioning MavenVersioning `xml:"versioning"`
}

MavenMetadata is the maven metadata xml root

type MavenVersioning added in v0.0.27

type MavenVersioning struct {
	XMLName xml.Name `xml:"versioning"`
	Latest  string   `xml:"latest"`
	Release string   `xml:"release"`
}

MavenVersioning is the versioning of maven

type OpenOption added in v0.0.10

type OpenOption struct {
	common.Option
	common.InteractiveOption

	Browser string

	Config bool
}

OpenOption is the open cmd option

type PluginBuildOptions added in v0.0.27

type PluginBuildOptions struct {
	common.Option

	DebugOutput bool
}

PluginBuildOptions for the plugin build command

type PluginCheckoutOption added in v0.0.23

type PluginCheckoutOption struct {
	RoundTripper http.RoundTripper
	// Timeout is the timeout setting for check Jenkins update-center
	Timeout int64
}

PluginCheckoutOption is the option for plugin checkout command

type PluginCreateOptions added in v0.0.23

type PluginCreateOptions struct {
	common.Option

	DebugOutput bool
}

PluginCreateOptions for the plugin create command

type PluginDownloadOption added in v0.0.23

type PluginDownloadOption struct {
	SkipDependency bool
	SkipOptional   bool
	UseMirror      bool
	Mirror         string
	ShowProgress   bool
	DownloadDir    string

	RoundTripper http.RoundTripper
}

PluginDownloadOption is the option for plugin download command

type PluginFormulaOption added in v0.0.31

type PluginFormulaOption struct {
	common.OutputOption

	// OnlyRelease indicated that we only output the release version of plugins
	OnlyRelease bool
	// DockerBuild indicated if build docker image
	DockerBuild  bool
	SortPlugins  bool
	RoundTripper http.RoundTripper
}

PluginFormulaOption option for plugin formula command

func (*PluginFormulaOption) Check added in v0.0.31

func (o *PluginFormulaOption) Check() (err error)

Check do the health check of plugin formula cmd

type PluginInstallOption added in v0.0.23

type PluginInstallOption struct {
	UseMirror    bool
	ShowProgress bool
	Formula      string

	RoundTripper http.RoundTripper
}

PluginInstallOption is the option for plugin install

type PluginListOption added in v0.0.18

type PluginListOption struct {
	common.OutputOption

	RoundTripper http.RoundTripper
}

PluginListOption option for plugin list command

type PluginOpenOption added in v0.0.24

type PluginOpenOption struct {
	ExecContext util.ExecContext

	Browser string
}

PluginOpenOption is the option of plugin open cmd

type PluginOptions

type PluginOptions struct {
	common.Option

	Suite string
}

PluginOptions contains the command line options

func (*PluginOptions) FindPlugin added in v0.0.24

func (o *PluginOptions) FindPlugin(name string) (plugin *client.InstalledPlugin, err error)

FindPlugin find a plugin by name

type PluginReleaseOptions added in v0.0.24

type PluginReleaseOptions struct {
	common.Option

	Batch       bool
	Prepare     bool
	Perform     bool
	SkipTests   bool
	DebugOutput bool
}

PluginReleaseOptions for the plugin create command

type PluginRunOptions added in v0.0.31

type PluginRunOptions struct {
	common.Option

	DebugOutput bool
}

PluginRunOptions for the plugin run command

type PluginSearchOption added in v0.0.18

type PluginSearchOption struct {
	common.OutputOption

	RoundTripper http.RoundTripper
}

PluginSearchOption is the plugin search option

func (*PluginSearchOption) Output added in v0.0.18

func (o *PluginSearchOption) Output(obj interface{}) (data []byte, err error)

Output output the data into buffer

type PluginTreadOption added in v0.0.21

type PluginTreadOption struct {
	RoundTripper http.RoundTripper
}

PluginTreadOption is the option of plugin trend command

type PluginUninstallOption added in v0.0.20

type PluginUninstallOption struct {
	RoundTripper http.RoundTripper
}

PluginUninstallOption the option of uninstall a plugin

type PluginUpgradeOption added in v0.0.20

type PluginUpgradeOption struct {
	Filter []string
	All    bool

	RoundTripper http.RoundTripper
}

PluginUpgradeOption option for plugin list command

type PluginUploadOption added in v0.0.18

type PluginUploadOption struct {
	Remote         string
	RemoteUser     string
	RemotePassword string
	RemoteJenkins  string
	ShowProgress   bool
	FileName       string
	// Timeout is the timeout when upload the plugin
	Timeout int64

	RoundTripper http.RoundTripper

	common.HookOption
	// contains filtered or unexported fields
}

PluginUploadOption will hold the options of plugin cmd

func (*PluginUploadOption) HPICompletion added in v0.0.28

func (o *PluginUploadOption) HPICompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

HPICompletion auto find the *.hpi files

type QueueCancelOption added in v0.0.20

type QueueCancelOption struct {
	RoundTripper http.RoundTripper
}

QueueCancelOption represents the option of queue cancel command

type QueueListOption added in v0.0.20

type QueueListOption struct {
	common.OutputOption

	RoundTripper http.RoundTripper
}

QueueListOption represents the option of queue list command

type RestartOption added in v0.0.18

type RestartOption struct {
	common.BatchOption
	common.Option

	Safe bool
}

RestartOption holds the options for restart cmd

type RootOptions added in v0.0.9

type RootOptions struct {
	ConfigFile string
	ConfigLoad bool
	Jenkins    string
	Debug      bool

	URL                string
	Username           string
	Token              string
	InsecureSkipVerify bool
	Proxy              string
	ProxyAuth          string
	ProxyDisable       bool
	Timeout            int64

	Doctor    bool
	StartTime time.Time
	EndTime   time.Time

	CommonOption *common.Option

	LoggerLevel string
}

RootOptions is a global option for whole cli

func GetRootOptions added in v0.0.29

func GetRootOptions() *RootOptions

GetRootOptions returns the root options

func (*RootOptions) GetCurrentJenkinsAndClient added in v0.0.30

func (o *RootOptions) GetCurrentJenkinsAndClient(jClient *client.JenkinsCore) *appCfg.JenkinsServer

GetCurrentJenkinsAndClient returns the current Jenkins

func (*RootOptions) GetCurrentJenkinsFromOptions added in v0.0.30

func (o *RootOptions) GetCurrentJenkinsFromOptions() *appCfg.JenkinsServer

GetCurrentJenkinsFromOptions returns the current Jenkins

func (*RootOptions) GetGitHubClient added in v0.0.30

func (o *RootOptions) GetGitHubClient() *github.Client

GetGitHubClient returns the GitHub client

func (*RootOptions) GetMirror added in v0.0.30

func (o *RootOptions) GetMirror(name string) string

GetMirror returns the mirror

func (*RootOptions) RunDiagnose added in v0.0.24

func (o *RootOptions) RunDiagnose(cmd *cobra.Command) (err error)

RunDiagnose run the diagnose for a specific command

func (*RootOptions) SetGitHubClient added in v0.0.30

func (o *RootOptions) SetGitHubClient(gitHubClient *github.Client)

SetGitHubClient set the GitHub client

type RunnerOption added in v0.0.29

type RunnerOption struct {
	common.BatchOption
	common.Option
	RoundTripper http.RoundTripper

	Safe            bool
	WarVersion      string
	WarPath         string
	PluginPath      string
	JenkinsfilePath string
	JfrVersion      string
	LTS             bool
}

RunnerOption is the wrapper of jenkinsfile runner cli

type ShellOptions added in v0.0.24

type ShellOptions struct {
	common.Option

	TmpDir            string
	TmpConfigFileName string
}

ShellOptions is the option of shell command

type ShutdownOption added in v0.0.29

type ShutdownOption struct {
	common.BatchOption
	common.Option
	RootOptions *RootOptions

	Safe          bool
	Prepare       bool
	CancelPrepare bool
}

ShutdownOption holds the options for shutdown cmd

type UserCreateOption added in v0.0.18

type UserCreateOption struct {
	RoundTripper http.RoundTripper
}

UserCreateOption is user create cmd option

type UserDeleteOption added in v0.0.18

type UserDeleteOption struct {
	common.BatchOption

	RoundTripper http.RoundTripper
}

UserDeleteOption is user delete cmd option

type UserEditOption added in v0.0.18

type UserEditOption struct {
	common.Option

	Description string
}

UserEditOption is the user edit cmd option

type UserOption added in v0.0.18

type UserOption struct {
	common.OutputOption

	RoundTripper http.RoundTripper
}

UserOption is the user cmd option

type UserTokenOption added in v0.0.18

type UserTokenOption struct {
	Generate   bool
	Name       string
	TargetUser string

	RoundTripper http.RoundTripper
}

UserTokenOption represents a user token cmd option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL