Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

Commit 04835db

Browse files
committed
set the GOPATH correctly for test, compile steps.
1 parent eecdb2b commit 04835db

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

pkg/engine/engine_golang.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (g *engineGolang) CompileStep() error {
137137

138138
if terr := g.ExecuteCmdList("engine_cmd_compile",
139139
g.PipelineData.GitLocalPath,
140-
nil,
140+
g.customGopathEnv(),
141141
"",
142142
"Compile command (%s) failed. Check log for more details.",
143143
); terr != nil {
@@ -161,7 +161,7 @@ func (g *engineGolang) TestStep() error {
161161
//run lint command
162162
if terr := g.ExecuteCmdList("engine_cmd_lint",
163163
g.PipelineData.GitLocalPath,
164-
nil,
164+
g.customGopathEnv(),
165165
"",
166166
"Lint command (%s) failed. Check log for more details.",
167167
); terr != nil {
@@ -172,7 +172,7 @@ func (g *engineGolang) TestStep() error {
172172
//code formatter
173173
if terr := g.ExecuteCmdList("engine_cmd_fmt",
174174
g.PipelineData.GitLocalPath,
175-
nil,
175+
g.customGopathEnv(),
176176
"",
177177
"Format command (%s) failed. Check log for more details.",
178178
); terr != nil {
@@ -184,7 +184,7 @@ func (g *engineGolang) TestStep() error {
184184
//run test command
185185
if terr := g.ExecuteCmdList("engine_cmd_test",
186186
g.PipelineData.GitLocalPath,
187-
nil,
187+
g.customGopathEnv(),
188188
"",
189189
"Test command (%s) failed. Check log for more details.",
190190
); terr != nil {
@@ -196,7 +196,7 @@ func (g *engineGolang) TestStep() error {
196196
//run security check command
197197
if terr := g.ExecuteCmdList("engine_cmd_security_check",
198198
g.PipelineData.GitLocalPath,
199-
nil,
199+
g.customGopathEnv(),
200200
"",
201201
"Dependency vulnerability check command (%s) failed. Check log for more details.",
202202
); terr != nil {
@@ -229,10 +229,17 @@ func (g *engineGolang) customGopathEnv() []string {
229229
updatedEnv := []string{fmt.Sprintf("GOPATH=%s", g.PipelineData.GolangGoPath)}
230230

231231
for i := range currentEnv {
232-
if !strings.HasPrefix(currentEnv[i], "GOPATH=") { //add all environmental variables that are not GOPATH
232+
if strings.HasPrefix(currentEnv[i], "GOPATH="){
233+
//skip
234+
continue
235+
} else if strings.HasPrefix(currentEnv[i], "PATH=") {
236+
updatedEnv = append(updatedEnv, fmt.Sprintf("PATH=%s/bin:%s", g.PipelineData.GolangGoPath, currentEnv[i]))
237+
} else {
238+
//add all environmental variables that are not GOPATH
233239
updatedEnv = append(updatedEnv, currentEnv[i])
234240
}
235241
}
242+
236243
return updatedEnv
237244
}
238245

pkg/mgr/mgr_golang_dep.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ func (m *mgrGolangDep) MgrDependenciesStep(currentMetadata interface{}, nextMeta
6363
if strings.HasPrefix(currentEnv[i], "GOPATH="){
6464
//skip
6565
continue
66-
} else if (strings.HasPrefix(currentEnv[i], "PATH=")) {
66+
} else if strings.HasPrefix(currentEnv[i], "PATH=") {
6767
updatedEnv = append(updatedEnv, fmt.Sprintf("PATH=%s/bin:%s", m.PipelineData.GolangGoPath, currentEnv[i]))
6868
} else {
6969
//add all environmental variables that are not GOPATH
7070
updatedEnv = append(updatedEnv, currentEnv[i])
7171
}
7272
}
7373

74+
print(updatedEnv)
75+
7476
if cerr := utils.BashCmdExec("dep ensure -v", m.PipelineData.GitLocalPath, updatedEnv, ""); cerr != nil {
7577
return errors.EngineTestDependenciesError("dep ensure failed. Check dep dependencies")
7678
}

0 commit comments

Comments
 (0)