File tree 2 files changed +43
-1
lines changed
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -106,3 +106,33 @@ func gitCloneRepo(repo *gaia.GitRepo) error {
106
106
107
107
return nil
108
108
}
109
+
110
+ func updateAllCurrentPipelines () {
111
+ // Get all active pipelines
112
+ for pipeline := range GlobalActivePipelines .Iter () {
113
+ r , err := git .PlainOpen (pipeline .Repo .LocalDest )
114
+ if err != nil {
115
+ // ignore for now
116
+ return
117
+ }
118
+
119
+ beforPull , _ := r .Head ()
120
+ tree , _ := r .Worktree ()
121
+ tree .Pull (& git.PullOptions {
122
+ RemoteName : "origin" ,
123
+ })
124
+ afterPull , _ := r .Head ()
125
+
126
+ // if there are no changes...
127
+ if beforPull .Hash () == afterPull .Hash () {
128
+ continue
129
+ }
130
+
131
+ // otherwise build the pipeline
132
+ b := newBuildPipeline (pipeline .Type )
133
+ createPipeline := & gaia.CreatePipeline {}
134
+ createPipeline .Pipeline = pipeline
135
+ b .ExecuteBuild (createPipeline )
136
+ }
137
+
138
+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ import (
18
18
const (
19
19
// tickerIntervalSeconds defines how often the ticker will tick.
20
20
// Definition in seconds.
21
- tickerIntervalSeconds = 5
21
+ tickerIntervalSeconds = 5
22
+ pollTicketIntervalMinutes = 1
22
23
)
23
24
24
25
// storeService is an instance of store.
@@ -52,6 +53,17 @@ func InitTicker(store *store.Store, scheduler *scheduler.Scheduler) {
52
53
}
53
54
}
54
55
}()
56
+
57
+ pollTicket := time .NewTicker (pollTicketIntervalMinutes * time .Minute )
58
+ go func () {
59
+ defer pollTicket .Stop ()
60
+ for {
61
+ select {
62
+ case <- pollTicket .C :
63
+ updateAllCurrentPipelines ()
64
+ }
65
+ }
66
+ }()
55
67
}
56
68
57
69
// checkActivePipelines looks up all files in the pipeline folder.
You can’t perform that action at this time.
0 commit comments