@@ -47,17 +47,19 @@ type (
4747 FinalizeWindows * Step `yaml:"finalize_windows,omitempty"`
4848 }
4949 Step struct {
50- Name * string `yaml:"name"`
51- Use string `yaml:"use"`
52- Cmd string `yaml:"cmd"`
53- Dir string `yaml:"dir"`
54- Env []string `yaml:"env"`
55- If []If `yaml:"if"`
50+ Name * string `yaml:"name"`
51+ Use string `yaml:"use"`
52+ Cmd string `yaml:"cmd"`
53+ Dir string `yaml:"dir"`
54+ Env []string `yaml:"env"`
55+ If []If `yaml:"if"`
56+ IgnoreError bool `yaml:"ignore_error" mapstructure:"ignore_error"`
5657 }
5758 If struct {
5859 Directory * IfExists `yaml:"directory,omitempty"`
5960 File * IfExists `yaml:"file,omitempty"`
6061 Env * []string `yarl:"env,omitempty"`
62+ IsError * bool `yaml:"is_error,omitempty" mapstructure:"is_error"`
6163 }
6264 IfExists struct {
6365 Exists * string `yaml:"exists,omitempty"`
@@ -345,6 +347,7 @@ func (e *Executor) finalizePlugins() (result error) {
345347
346348func (e * Executor ) runJob (name string , job * Job ) (result error ) {
347349 util .LogInfo ("[lscbuild] start job: %s\n " , name )
350+ util .LogDebug ("[lscbuild] job: %+v\n " , job )
348351 defer func () {
349352 if err := recover (); err != nil {
350353 switch e := err .(type ) {
@@ -374,6 +377,15 @@ func (e *Executor) runJob(name string, job *Job) (result error) {
374377 }
375378
376379 for _ , step := range job .Steps {
380+ if result != nil && ! step .IsError () {
381+ util .LogInfo ("[lscbuild] skip step: %s\n " , e .stepName (& step ))
382+ continue
383+ }
384+ if result == nil && step .IsError () {
385+ util .LogInfo ("[lscbuild] skip step: %s\n " , e .stepName (& step ))
386+ continue
387+ }
388+
377389 if step .Use != "" {
378390 parsed := e .parsePluginUse (step .Use )
379391 cache := e .pluginCache [parsed .GitRepo ]
@@ -389,15 +401,13 @@ func (e *Executor) runJob(name string, job *Job) (result error) {
389401 newStep .Env = append (newStep .Env , "LSCBUILD_CWD=" + cwd )
390402
391403 result = e .runStep (job , & newStep )
392- if result != nil {
393- return result
394- }
395404 }
396405 } else {
397406 result = e .runStep (job , & step )
398- if result != nil {
399- return result
400- }
407+ }
408+
409+ if step .IgnoreError {
410+ result = nil
401411 }
402412 }
403413
@@ -519,6 +529,9 @@ func (e *Executor) runStep(job *Job, step *Step) (result error) {
519529 cmd .Stderr = os .Stderr
520530
521531 util .LogInfo ("[lscbuild] start step: %s\n " , stepName )
532+ defer func () {
533+ util .LogInfo ("[lscbuild] end step: %s, exit status: %d\n " , stepName , cmd .ProcessState .ExitCode ())
534+ }()
522535
523536 if err := cmd .Start (); err != nil {
524537 result = err
@@ -529,11 +542,21 @@ func (e *Executor) runStep(job *Job, step *Step) (result error) {
529542 return result
530543 }
531544
532- util .LogInfo ("[lscbuild] end step: %s\n " , stepName )
533-
534545 return result
535546}
536547
548+ func (s * Step ) IsError () bool {
549+ if s .If == nil {
550+ return false
551+ }
552+ for _ , i := range s .If {
553+ if i .IsError != nil && * i .IsError {
554+ return true
555+ }
556+ }
557+ return false
558+ }
559+
537560func (s * Step ) MustCopy () Step {
538561 // FIXME: slow zone
539562
0 commit comments