Skip to content

Commit 41dfead

Browse files
committed
feat(job): expose more variables as part of the task details
1 parent af30b64 commit 41dfead

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

services/tasks/LocalJob.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package tasks
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/semaphoreui/semaphore/pkg/ssh"
76
"maps"
87
"os"
98
"strings"
109

10+
"github.com/semaphoreui/semaphore/pkg/ssh"
11+
1112
"path"
1213
"strconv"
1314

@@ -64,6 +65,9 @@ func (t *LocalJob) SetStatus(status task_logger.TaskStatus) {
6465
}
6566

6667
func (t *LocalJob) SetCommit(hash, message string) {
68+
// TODO: is this the correct place to do?
69+
t.Task.CommitHash = &hash
70+
t.Task.CommitMessage = message
6771
t.Logger.SetCommit(hash, message)
6872
}
6973

@@ -88,6 +92,12 @@ func (t *LocalJob) getEnvironmentExtraVars(username string, incomingVersion *str
8892

8993
taskDetails["username"] = username
9094
taskDetails["url"] = t.Task.GetUrl()
95+
taskDetails["commit_hash"] = t.Task.CommitHash
96+
taskDetails["commit_message"] = t.Task.CommitMessage
97+
taskDetails["inventory_name"] = t.Inventory.Name
98+
taskDetails["inventory_id"] = t.Inventory.ID
99+
taskDetails["repository_name"] = t.Repository.Name
100+
taskDetails["repository_id"] = t.Repository.ID
91101

92102
if t.Template.Type != db.TemplateTask {
93103
taskDetails["type"] = t.Template.Type
@@ -136,6 +146,12 @@ func (t *LocalJob) getEnvironmentExtraVarsJSON(username string, incomingVersion
136146

137147
taskDetails["username"] = username
138148
taskDetails["url"] = t.Task.GetUrl()
149+
taskDetails["commit_hash"] = t.Task.CommitHash
150+
taskDetails["commit_message"] = t.Task.CommitMessage
151+
taskDetails["inventory_name"] = t.Inventory.Name
152+
taskDetails["inventory_id"] = t.Inventory.ID
153+
taskDetails["repository_name"] = t.Repository.Name
154+
taskDetails["repository_id"] = t.Repository.ID
139155

140156
if t.Template.Type != db.TemplateTask {
141157
taskDetails["type"] = t.Template.Type

0 commit comments

Comments
 (0)