Exemple #1
0
// createJob adds a new job to the database.
func (p *pushCallback) createJob() error {
	if p.shouldRun() == false {
		log.Println("Not adding", p.repositoryURL(), p.branch())
		return nil
	}

	repo := database.GetRepository(p.repositoryURL())

	job := database.CreateJob(
		repo,
		p.branch(),
		p.commit(),
		p.commitURL(),
		p.name(),
		p.email(),
	)

	status := make(chan bool, 1)

	queueJob := runner.QueueJob{
		JobID:  job.ID,
		Status: status,
	}

	queueJob.Enqueue()

	if repo.StatusPR {
		<-status
		job = database.GetJob(job.ID)
		postStatus(job, repo, p.statusURL())
	}

	return nil
}
Exemple #2
0
// viewRerunJob resets a job status and enqueues it agian.
func viewRerunJob(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	jobID, _ := strconv.Atoi(vars["jid"])

	old := database.GetJob(int64(jobID))
	job := database.CreateJob(
		&old.Repository,
		old.Branch,
		old.Commit,
		old.CommitURL,
		old.Name,
		old.Email,
	)

	queueJob := runner.QueueJob{
		JobID: job.ID,
	}

	queueJob.Enqueue()

	http.Redirect(w, r, "/", 302)
}