Example #1
0
func (self *FullGCInvoker) IsConfigAcceptable(config *util.Config) bool {
	if config.ForceFullGC && !config.HasCIConnection() {
		util.GOut("gc", "WARN: No Jenkins URI defined. System.GC() cannot be called inside the Jenkins client.")
		return false
	}
	return true
}
func (self *NodeNameHandler) Prepare(config *util.Config) {
	if !config.HasCIConnection() {
		return
	}

	if foundNode, err := self.verifyNodeName(config); err == nil {

		if !foundNode {
			if config.CreateClientIfMissing {
				if err := self.createNode(config); err == nil {
					util.GOut("naming", "Created node '%s' in Jenkins.", config.ClientName)
				} else {
					util.GOut("naming", "ERROR: Failed to create node '%s' in Jenkins. Cause: %v", config.ClientName, err)
				}
				foundNode, _ = self.verifyNodeName(config)
			} else {
				util.GOut("naming", "Will not attempt to auto generate node '%s' in Jenkins. Enable this with '-create' or within the configuration.", config.ClientName)
			}
		}

		if foundNode {
			util.GOut("naming", "Found client node name in Jenkins, using '%v'.", config.ClientName)
		} else {
			util.GOut("naming", "WARN: Client node name '%v' was %s in Jenkins. Likely the next operations will fail.", config.ClientName, "NOT FOUND")
		}
	} else {
		util.GOut("nameing", "ERROR: Failed to verify the client node name in Jenkins. Cause: %v", err)
	}
}
func (self *JenkinsNodeMonitor) IsConfigAcceptable(config *util.Config) bool {
	if config.ClientMonitorStateOnServer && !config.HasCIConnection() {
		util.GOut("monitor", "No Jenkins URI defined. Cannot monitor this node within Jenkins.")
		return false
	}
	return true
}
func (self *SSHTunnelEstablisher) IsConfigAcceptable(config *util.Config) bool {
	if config.CITunnelSSHEnabled && config.CITunnelSSHAddress == "" {
		util.GOut("ssh-tunnel", "WARN: SSH tunnel is enabled but SSH server address is empty.")
		return false
	}
	if config.CITunnelSSHAddress != "" && !config.HasCIConnection() {
		util.GOut("ssh-tunnel", "WARN: No Jenkins URI defined. SSH tunnel settings are not enough to connect to Jenkins.")
		return false
	}
	return true
}
func (self *ClientMode) IsConfigAcceptable(config *util.Config) bool {
	if !config.HasCIConnection() {
		util.GOut(self.Name(), "ERROR: No Jenkins URI defined. Cannot connect to the CI server.")
		return false
	}

	if config.SecretKey == "" && !self.isAuthCredentialsPassedViaCommandline(config) {
		if config.SecretKey = self.getSecretFromJenkins(config); config.SecretKey == "" {
			util.GOut(self.Name(), "ERROR: No secret key set for node %v and the attempt to fetch it from Jenkins failed.", config.ClientName)
			return false
		}
	}

	return true
}
func (self *JenkinsClientDownloader) Prepare(config *util.Config) {
	util.ClientJar, _ = filepath.Abs(ClientJarName)

	modes.RegisterModeListener(func(mode modes.ExecutableMode, nextStatus int32, config *util.Config) {
		if mode.Name() == "client" && nextStatus == modes.ModeStarting && config.HasCIConnection() {
			if err := self.downloadJar(config); err != nil {
				jar, e := os.Open(ClientJarName)
				defer jar.Close()
				if os.IsNotExist(e) {
					panic(fmt.Sprintf("No jenkins client: %s", err))
				} else {
					util.GOut("DOWNLOAD", "%s", err)
				}
			}
		}
	})
}