Skip to content

Commit

Permalink
fix: periodics job variables
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Jan 10, 2024
1 parent c6dff78 commit 5710f09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 0 additions & 4 deletions pkg/apis/lighthouse/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ func (s *LighthouseJobSpec) GetEnvVars() map[string]string {

env[JobSpecEnv] = fmt.Sprintf("type:%s", s.Type)

if s.Type == job.PeriodicJob {
return env
}

if s.Refs != nil {
env[RepoOwnerEnv] = s.Refs.Org
env[RepoNameEnv] = s.Refs.Repo
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/job/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type Periodic struct {
Reporter
// Cron representation of job trigger time
Cron string `json:"cron"`
// Branch to run job on. If not set default branch for repository is used
Branch string `json:"branch,omitempty"`
}

// SetDefaults initializes default values
Expand Down
7 changes: 4 additions & 3 deletions pkg/plugins/trigger/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ func (pa *PeriodicAgent) UpdatePeriodicsForRepo(
continue
}
refs := v1alpha1.Refs{
Org: org,
Repo: repo,
Org: org,
Repo: repo,
BaseRef: p.Branch,
}

pj := jobutil.NewLighthouseJob(jobutil.PeriodicSpec(l, p, refs), labels, p.Annotations)
Expand Down Expand Up @@ -402,7 +403,7 @@ func (pa *PeriodicAgent) constructCronJob(resourceName, configMapName string, la
WithContainers((&applyv1.ContainerApplyConfiguration{}).
WithName("create-lighthousejob").
WithImage("bitnami/kubectl").
WithCommand("/bin/sh").
WithCommand("/bin/bash").
WithArgs("-c", `
set -o errexit
create_output=$(kubectl create -f /config/lighthousejob.json)
Expand Down

0 comments on commit 5710f09

Please sign in to comment.