mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-22 04:40:11 +00:00
got the build working correctly
This commit is contained in:
@@ -26,13 +26,14 @@ type BuildTask struct {
|
||||
}
|
||||
|
||||
// Start N workers with the given build runner.
|
||||
func Start(workers int, runner BuildRunner) *Queue {
|
||||
func Start(workers int, commits commit.CommitManager, runner BuildRunner) *Queue {
|
||||
tasks := make(chan *BuildTask)
|
||||
queue := &Queue{tasks: tasks}
|
||||
|
||||
for i := 0; i < workers; i++ {
|
||||
worker := worker{
|
||||
runner: runner,
|
||||
runner: runner,
|
||||
commits: commits,
|
||||
}
|
||||
|
||||
go worker.work(tasks)
|
||||
|
@@ -8,6 +8,7 @@ import (
|
||||
r "github.com/drone/drone/shared/build/repo"
|
||||
"github.com/drone/drone/shared/build/script"
|
||||
"io"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -34,7 +35,10 @@ func (w *worker) work(queue <-chan *BuildTask) {
|
||||
}
|
||||
|
||||
// execute the task
|
||||
w.execute(task)
|
||||
err := w.execute(task)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +61,7 @@ func (w *worker) execute(task *BuildTask) error {
|
||||
params, err := task.Repo.ParamMap()
|
||||
task.Script, err = script.ParseBuild(task.Commit.Config, params)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing repository params. %s\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -66,6 +71,7 @@ func (w *worker) execute(task *BuildTask) error {
|
||||
|
||||
// persist the commit to the database
|
||||
if err := w.commits.Update(task.Commit); err != nil {
|
||||
log.Printf("Error updating commit. %s\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -166,7 +172,7 @@ func (w *worker) execute(task *BuildTask) error {
|
||||
func (w *worker) runBuild(task *BuildTask, buf io.Writer) (bool, error) {
|
||||
repo := &r.Repo{
|
||||
Name: task.Repo.Host + task.Repo.Owner + task.Repo.Name,
|
||||
Path: task.Repo.URL,
|
||||
Path: task.Repo.CloneURL,
|
||||
Branch: task.Commit.Branch,
|
||||
Commit: task.Commit.Sha,
|
||||
PR: task.Commit.PullRequest,
|
||||
@@ -175,6 +181,10 @@ func (w *worker) runBuild(task *BuildTask, buf io.Writer) (bool, error) {
|
||||
Depth: git.GitDepth(task.Script.Git),
|
||||
}
|
||||
|
||||
if task.Repo.Private {
|
||||
repo.Path = task.Repo.SSHURL
|
||||
}
|
||||
|
||||
return w.runner.Run(
|
||||
task.Script,
|
||||
repo,
|
||||
|
Reference in New Issue
Block a user