@@ -2,7 +2,6 @@ package pipeline
22
33import (
44"fmt"
5- "path/filepath"
65
76"github.com/gaia-pipeline/gaia"
87"github.com/gaia-pipeline/gaia/services"
@@ -15,8 +14,8 @@ const (
1514// Percent of pipeline creation progress after compile process done
1615pipelineCompileStatus = 50
1716
18- // Percent of pipeline creation progress after validation binary copy
19- pipelineCopyStatus = 75
17+ // Percent of pipeline creation progress after validation
18+ pipelineValidateStatus = 75
2019
2120// Completed percent progress
2221pipelineCompleteStatus = 100
@@ -81,33 +80,12 @@ func CreatePipeline(p *gaia.CreatePipeline) {
8180return
8281}
8382
84- // Copy compiled binary to plugins folder
85- err = bP .CopyBinary (p )
86- if err != nil {
87- p .StatusType = gaia .CreatePipelineFailed
88- p .Output = fmt .Sprintf ("cannot copy compiled binary: %s" ,err .Error ())
89- storeService .CreatePipelinePut (p )
90- return
91- }
92-
93- // Update status of our pipeline build
94- p .Status = pipelineCopyStatus
95- err = storeService .CreatePipelinePut (p )
96- if err != nil {
97- gaia .Cfg .Logger .Error ("cannot put create pipeline into store" ,"error" ,err .Error ())
98- return
99- }
100-
10183// Run update if needed
102- p .Pipeline .ExecPath = filepath .Join (gaia .Cfg .PipelinePath ,appendTypeToName (p .Pipeline .Name ,p .Pipeline .Type ))
10384err = updatePipeline (& p .Pipeline )
10485if err != nil {
10586p .StatusType = gaia .CreatePipelineFailed
10687p .Output = fmt .Sprintf ("cannot update pipeline: %s" ,err .Error ())
10788storeService .CreatePipelinePut (p )
108-
109- // Creation failed. Remove broken pipeline.
110- DeleteBinary (p .Pipeline )
11189return
11290}
11391
@@ -117,9 +95,14 @@ func CreatePipeline(p *gaia.CreatePipeline) {
11795p .StatusType = gaia .CreatePipelineFailed
11896p .Output = fmt .Sprintf ("cannot validate pipeline: %s" ,err .Error ())
11997storeService .CreatePipelinePut (p )
98+ return
99+ }
120100
121- // Creation failed. Remove broken pipeline.
122- DeleteBinary (p .Pipeline )
101+ // Update status of our pipeline build
102+ p .Status = pipelineValidateStatus
103+ err = storeService .CreatePipelinePut (p )
104+ if err != nil {
105+ gaia .Cfg .Logger .Error ("cannot put create pipeline into store" ,"error" ,err .Error ())
123106return
124107}
125108
@@ -132,6 +115,15 @@ func CreatePipeline(p *gaia.CreatePipeline) {
132115return
133116}
134117
118+ // Copy compiled binary to plugins folder which is the final step
119+ err = bP .CopyBinary (p )
120+ if err != nil {
121+ p .StatusType = gaia .CreatePipelineFailed
122+ p .Output = fmt .Sprintf ("cannot copy compiled binary: %s" ,err .Error ())
123+ storeService .CreatePipelinePut (p )
124+ return
125+ }
126+
135127// Set create pipeline status to complete
136128p .Status = pipelineCompleteStatus
137129p .StatusType = gaia .CreatePipelineSuccess