Job exection logic now runs pipeline in container
This container's network is configured based on parameters in the config file. If configured correctly, this will allow the pipeline script to speak to the cursorius server over the pipeline api.
This commit is contained in:
+12
-8
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"git.ohea.xyz/cursorius/server/config"
|
||||
"git.ohea.xyz/cursorius/server/jobscheduler"
|
||||
"git.ohea.xyz/cursorius/server/pipeline_executor"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
@@ -24,7 +25,7 @@ type tag struct {
|
||||
commitHash string
|
||||
}
|
||||
|
||||
func pollJob(repoName string, jobConfig config.Job, runCh chan jobscheduler.Run) {
|
||||
func pollJob(repoName string, jobConfig config.Job, runCh chan jobscheduler.Run, pipelineConf config.PipelineConf) {
|
||||
prevCommits := make(map[string]string)
|
||||
for {
|
||||
time.Sleep(time.Duration(jobConfig.PollInterval) * time.Second)
|
||||
@@ -91,21 +92,24 @@ func pollJob(repoName string, jobConfig config.Job, runCh chan jobscheduler.Run)
|
||||
|
||||
for _, ref := range refsToRunFor {
|
||||
log.Debugf("Dispatching job for ref %v in repo %v", ref, repoName)
|
||||
runCh <- jobscheduler.Run{
|
||||
JobName: repoName,
|
||||
JobConfig: jobConfig,
|
||||
Ref: ref,
|
||||
|
||||
pe := pipeline_executor.PipelineExecution{
|
||||
Name: repoName,
|
||||
Job: jobConfig,
|
||||
Ref: ref,
|
||||
}
|
||||
|
||||
pipeline_executor.ExecutePipeline(pe, pipelineConf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func StartPolling(jobs map[string]config.Job, runCh chan jobscheduler.Run) {
|
||||
for jobName, job := range jobs {
|
||||
func StartPolling(conf config.Config, runCh chan jobscheduler.Run) {
|
||||
for jobName, job := range conf.Jobs {
|
||||
if job.PollInterval == 0 {
|
||||
continue
|
||||
} else {
|
||||
go pollJob(jobName, job, runCh)
|
||||
go pollJob(jobName, job, runCh, conf.PipelineConf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user