Esempio n. 1
0
func listenDeploys(lastMarker string, commandMsgs chan<- models.Message, connector models.Connector) (nextMarker string) {
	now := time.Now()
	nextMarker = strconv.FormatInt(now.Unix(), 10) + "000"
	if connector.Debug {
		log.Print("Calling deploy results with last marker: " + lastMarker)
	}
	d := bambooapi.DeployResults(connector.Server, connector.Login, connector.Pass)
	for _, de := range d {
		for _, e := range de.Environmentstatuses {
			buildTime := strconv.FormatInt(e.Deploymentresult.Finisheddate, 10)
			if e.Deploymentresult.ID > 0 && buildTime > lastMarker {
				var m models.Message
				m.In.ConnectorType = connector.Type
				m.In.ConnectorID = connector.ID
				m.In.Tags = connector.Tags
				m.In.Process = false
				m.Out.Text = "Bamboo Deploy " + e.Deploymentresult.Deploymentversion.Planbranchname + " " + e.Deploymentresult.Deploymentversion.Name + " to " + e.Environment.Name + " " + e.Deploymentresult.Deploymentstate
				m.Out.Detail = html.UnescapeString(sanitize.HTML(e.Deploymentresult.Reasonsummary))
				m.Out.Link = "https://" + connector.Server + "/builds/deploy/viewDeploymentResult.action?deploymentResultId=" + strconv.Itoa(e.Deploymentresult.ID)
				if e.Deploymentresult.Deploymentstate == "SUCCESS" {
					m.Out.Status = "SUCCESS"
				} else {
					m.Out.Status = "FAIL"
				}
				commandMsgs <- m
			}
		}
	}
	return nextMarker
}
Esempio n. 2
0
func commandDeployStatus(message models.Message, publishMsgs chan<- models.Message, connector models.Connector) {
	tokens := strings.Split(message.In.Text, " ")
	d := bambooapi.DeployResults(connector.Server, connector.Login, connector.Pass)
	for _, de := range d {
		for _, e := range de.Environmentstatuses {
			detail := e.Deploymentresult.Deploymentversion.Name + " to " + e.Environment.Name
			if strings.Contains(strings.ToLower(detail), strings.ToLower(tokens[2])) {
				message.In.Tags = parse.TagAppend(message.In.Tags, connector.Tags)
				message.Out.Text = "Bamboo Deploy " + detail + " " + e.Deploymentresult.Deploymentstate
				message.Out.Detail = html.UnescapeString(sanitize.HTML(e.Deploymentresult.Reasonsummary))
				message.Out.Link = "https://" + connector.Server + "/builds/deploy/viewDeploymentResult.action?deploymentResultId=" + strconv.Itoa(e.Deploymentresult.ID)
				if e.Deploymentresult.Deploymentstate == "SUCCESS" {
					message.Out.Status = "SUCCESS"
				} else {
					message.Out.Status = "FAIL"
				}
				publishMsgs <- message
			}
		}
	}
}