当前位置: 首页>>代码示例>>Golang>>正文


Golang Config.CIGet方法代码示例

本文整理汇总了Golang中github.com/jkellerer/jenkins-client-launcher/launcher/util.Config.CIGet方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.CIGet方法的具体用法?Golang Config.CIGet怎么用?Golang Config.CIGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jkellerer/jenkins-client-launcher/launcher/util.Config的用法示例。


在下文中一共展示了Config.CIGet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetJenkinsNodeConfig

// Returns the current configuration of this Jenkins node from the Jenkins server.
func GetJenkinsNodeConfig(config *util.Config) (*JenkinsNodeConfig, error) {
	if response, err := config.CIGet(fmt.Sprintf("/computer/%s/config.xml", config.ClientName)); err == nil {
		defer response.Body.Close()
		if response.StatusCode == 200 {
			config := &JenkinsNodeConfig{}
			err = xml.NewDecoder(response.Body).Decode(config)
			return config, err
		} else {
			return nil, fmt.Errorf(response.Status)
		}
	} else {
		return nil, err
	}
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:15,代码来源:cleanup.go

示例2: GetAllRegisteredNodesInJenkins

// Returns the names of all nodes that are registered in Jenkins.
func GetAllRegisteredNodesInJenkins(config *util.Config) (*AllComputerNames, error) {
	response, err := config.CIGet(ComputersURI)
	if err == nil && response.StatusCode == 200 {
		defer response.Body.Close()
		names := new(AllComputerNames)
		err = xml.NewDecoder(response.Body).Decode(names)
		return names, err
	} else {
		if err == nil && response != nil {
			err = fmt.Errorf(response.Status)
		}
		return nil, err
	}
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:15,代码来源:naming.go

示例3: GetJenkinsNodeStatus

// Returns the current offline and idle status of this Jenkins node from the Jenkins server.
func GetJenkinsNodeStatus(config *util.Config) (*JenkinsNodeStatus, error) {
	if response, err := config.CIGet(fmt.Sprintf(NodeMonitoringURI, config.ClientName)); err == nil {
		defer response.Body.Close()
		if response.StatusCode == 200 {
			status := &JenkinsNodeStatus{}
			err = xml.NewDecoder(response.Body).Decode(status)
			return status, err
		} else {
			return nil, fmt.Errorf(response.Status)
		}
	} else {
		return nil, err
	}
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:15,代码来源:monitor.go

示例4: getJNLPListenerPort

// Gets the port that is used by the JNLP client to communicate with Jenkins.
// Returns the port number as string and an error if fetching the port failed for any reason.
func (self *SSHTunnelEstablisher) getJNLPListenerPort(config *util.Config) (port string, err error) {
	var response *http.Response
	port = ""

	if response, err = config.CIGet("/tcpSlaveAgentListener/"); err == nil {
		response.Body.Close()
		if response.StatusCode == 200 {
			if port = response.Header.Get("X-Jenkins-JNLP-Port"); port == "" {
				port = response.Header.Get("X-Hudson-JNLP-Port")
			}
		}

		if port == "" {
			err = fmt.Errorf("Jenkins did not provide the JNLP-Port, the reply was %v.", response.Status)
		}
	}

	return
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:21,代码来源:sshtunnel.go

示例5: getCustomizedAgentJnlp

func (self *ClientMode) getCustomizedAgentJnlp(config *util.Config) []byte {
	response, err := config.CIGet(fmt.Sprintf("computer/%s/slave-agent.jnlp", config.ClientName))
	if err == nil {
		defer response.Body.Close()

		if response.StatusCode == 200 {
			var content []byte
			if content, err = ioutil.ReadAll(response.Body); err == nil {
				return self.applyCustomJnlpArgs(config, content)
			}
		} else {
			util.GOut("client", "ERROR: Failed JNLP config from Jenkins. Cause: %v", response.Status)
		}
	}

	if err != nil {
		util.GOut("client", "ERROR: Failed JNLP config from Jenkins. Cause: %v", err)
	}

	return nil
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:21,代码来源:client.go

示例6: getSecretFromJenkins

func (self *ClientMode) getSecretFromJenkins(config *util.Config) string {
	response, err := config.CIGet(fmt.Sprintf("computer/%s/", config.ClientName))
	if err == nil {
		defer response.Body.Close()

		if response.StatusCode == 200 {
			var content []byte
			if content, err = ioutil.ReadAll(response.Body); err == nil {
				return self.extractSecret(content)
			}
		} else {
			util.GOut("client", "ERROR: Failed fetching secret key from Jenkins. Cause: %v", response.Status)
		}
	}

	if err != nil {
		util.GOut("client", "ERROR: Failed fetching secret key from Jenkins. Cause: %v", err)
	}

	return ""
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:21,代码来源:client.go

示例7: createNode

func (self *NodeNameHandler) createNode(config *util.Config) error {
	toJson := func(v interface{}) string {
		if content, err := json.Marshal(v); err == nil {
			return string(content)
		} else {
			return fmt.Sprintf("{\"error\": \"%v\"}", err)
		}
	}

	cwd, _ := os.Getwd()
	mode := "EXCLUSIVE"                                   // NORMAL or EXCLUSIVE (tied jobs only)
	retention := "hudson.slaves.RetentionStrategy$Always" // Always on

	params := make(url.Values)
	params.Set("name", config.ClientName)
	params.Set("type", ExpectedNodeType)
	params.Set("json", toJson(map[string]interface{}{
		"name":              config.ClientName,
		"nodeDescription":   fmt.Sprintf("JSL auto generated node '%s'.", config.ClientName),
		"numExecutors":      1,
		"remoteFS":          cwd,
		"labelString":       fmt.Sprintf("JSL %s %s", runtime.GOOS, runtime.GOARCH),
		"mode":              mode,
		"type":              ExpectedNodeType,
		"retentionStrategy": map[string]interface{}{"stapler-class": retention},
		"nodeProperties":    map[string]interface{}{"stapler-class-bag": true},
		"launcher":          map[string]interface{}{"stapler-class": ExpectedNodeLauncher},
	}))

	if response, err := config.CIGet(CreateNodeURI + "?" + params.Encode()); err == nil {
		response.Body.Close()
		if response.StatusCode == 200 {
			return nil
		} else {
			return fmt.Errorf("Create node failed. Jenkins returned %v", response.Status)
		}
	} else {
		return err
	}
}
开发者ID:jkellerer,项目名称:jenkins-client-launcher,代码行数:40,代码来源:naming.go


注:本文中的github.com/jkellerer/jenkins-client-launcher/launcher/util.Config.CIGet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。