@@ -2,7 +2,6 @@ package pipeline
2
2
3
3
import (
4
4
"fmt"
5
- "path/filepath"
6
5
7
6
"github.com/gaia-pipeline/gaia"
8
7
"github.com/gaia-pipeline/gaia/services"
@@ -15,8 +14,8 @@ const (
15
14
// Percent of pipeline creation progress after compile process done
16
15
pipelineCompileStatus = 50
17
16
18
- // Percent of pipeline creation progress after validation binary copy
19
- pipelineCopyStatus = 75
17
+ // Percent of pipeline creation progress after validation
18
+ pipelineValidateStatus = 75
20
19
21
20
// Completed percent progress
22
21
pipelineCompleteStatus = 100
@@ -81,33 +80,12 @@ func CreatePipeline(p *gaia.CreatePipeline) {
81
80
return
82
81
}
83
82
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
-
101
83
// Run update if needed
102
- p .Pipeline .ExecPath = filepath .Join (gaia .Cfg .PipelinePath , appendTypeToName (p .Pipeline .Name , p .Pipeline .Type ))
103
84
err = updatePipeline (& p .Pipeline )
104
85
if err != nil {
105
86
p .StatusType = gaia .CreatePipelineFailed
106
87
p .Output = fmt .Sprintf ("cannot update pipeline: %s" , err .Error ())
107
88
storeService .CreatePipelinePut (p )
108
-
109
- // Creation failed. Remove broken pipeline.
110
- DeleteBinary (p .Pipeline )
111
89
return
112
90
}
113
91
@@ -117,9 +95,14 @@ func CreatePipeline(p *gaia.CreatePipeline) {
117
95
p .StatusType = gaia .CreatePipelineFailed
118
96
p .Output = fmt .Sprintf ("cannot validate pipeline: %s" , err .Error ())
119
97
storeService .CreatePipelinePut (p )
98
+ return
99
+ }
120
100
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 ())
123
106
return
124
107
}
125
108
@@ -132,6 +115,15 @@ func CreatePipeline(p *gaia.CreatePipeline) {
132
115
return
133
116
}
134
117
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
+
135
127
// Set create pipeline status to complete
136
128
p .Status = pipelineCompleteStatus
137
129
p .StatusType = gaia .CreatePipelineSuccess
0 commit comments