@@ -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
0 commit comments