Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita74748f

Browse files
authored
Implement pipeline scheduling via cron syntax (#139)
* First UI layout for new option* Added validity check for new cron entries* Added new robfig/cron dependency* Implemented periodic scheduling* Added a few tests* Fixed test* Added test for ticker
1 parent9bcc31d commita74748f

File tree

18 files changed

+1451
-150
lines changed

18 files changed

+1451
-150
lines changed

‎Gopkg.lock‎

Lines changed: 22 additions & 120 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎frontend/client/views/pipeline/create.vue‎

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<spanclass="icon">
3131
<iclass="fa fa-certificate"></i>
3232
</span>
33-
<span>Addcredentials</span>
33+
<span>AddCredentials</span>
3434
</a>
3535
<aclass="button is-primary"v-on:click="showGitHubWebHookModal">
3636
<spanclass="icon">
@@ -39,7 +39,26 @@
3939
<span>Add GitHub WebHook</span>
4040
</a>
4141
</p>
42-
<hrclass="dotted-line">
42+
</div>
43+
</article>
44+
45+
<articleclass="tile is-child notification content-article">
46+
<divclass="content">
47+
<pclass="control">
48+
<labelclass="label">Define custom pipeline options here.</label>
49+
<aclass="button is-primary"v-on:click="showPeriodicalPipelineScheduleModal">
50+
<spanclass="icon">
51+
<iclass="fa fa-calendar"></i>
52+
</span>
53+
<span>Add Pipeline Trigger</span>
54+
</a>
55+
</p>
56+
<spanstyle="color:red"v-if="periodicSchedulesErr">Periodic schedules invalid: {{ periodicSchedulesErrMsg }}</span>
57+
</div>
58+
</article>
59+
60+
<articleclass="tile is-child notification content-article">
61+
<divclass="content">
4362
<labelclass="label">Type the name of your pipeline here.</label>
4463
<pclass="control has-icons-left"v-bind:class="{ 'has-icons-right': pipelineNameSuccess }">
4564
<inputclass="input is-medium input-bar"v-model="pipelinename"v-on:input="checkPipelineNameAvailableDebounce"type="text"placeholder="Pipeline name ...">
@@ -51,13 +70,6 @@
5170
</span>
5271
</p>
5372
<spanstyle="color:red"v-if="pipelineErrorMsg">Pipeline Name incorrect: {{ pipelineErrorMsg }}</span>
54-
<hrclass="dotted-line">
55-
<aclass="button is-green-button"v-on:click="startCreatePipeline"v-bind:class="{ 'is-disabled': !gitSuccess || !pipelineNameSuccess }">
56-
<spanclass="icon">
57-
<iclass="fa fa-plus"></i>
58-
</span>
59-
<span>Create Pipeline</span>
60-
</a>
6173
</div>
6274
</article>
6375
</div>
@@ -88,6 +100,17 @@
88100
</div>
89101
</div>
90102

103+
<divclass="tile is-parent">
104+
<articleclass="is-child notification content-article">
105+
<aclass="button is-green-button"style="margin-left:13px;"v-on:click="startCreatePipeline"v-bind:class="{ 'is-disabled': !gitSuccess || !pipelineNameSuccess || periodicSchedulesErr }">
106+
<spanclass="icon">
107+
<iclass="fa fa-plus"></i>
108+
</span>
109+
<span>Create Pipeline</span>
110+
</a>
111+
</article>
112+
</div>
113+
91114
<divclass="tile is-parent is-10">
92115
<articleclass="tile is-child notification content-article box">
93116
<vue-good-table
@@ -214,6 +237,36 @@
214237
</div>
215238
</modal>
216239

240+
<!-- periodical pipeline schedule modal-->
241+
<modal:visible="periodicalPipelineScheduleModal"class="modal-z-index"@close="close">
242+
<divclass="box credentials-modal">
243+
<divclass="block credentials-modal-content">
244+
<collapseaccordionis-fullwidth>
245+
<collapse-itemtitle="Start pipeline periodically:"selected>
246+
<divclass="credentials-modal-content">
247+
<pclass="control">
248+
<textareaclass="textarea input-bar"v-model="periodicSchedules"></textarea>
249+
</p>
250+
</div>
251+
<labelclass="label"style="test-align:left;">
252+
Use the standard cron syntax. For example to start the pipeline every half hour:
253+
<br />0 30 * * * *<br />
254+
Please see <ahref="https://godoc.org/github.com/robfig/cron"target="_blank">here</a> for more information.
255+
</label>
256+
</collapse-item>
257+
</collapse>
258+
<divclass="modal-footer">
259+
<divstyle="float:left;">
260+
<buttonclass="button is-primary"v-on:click="addPeriodicalSchedules">Confirm</button>
261+
</div>
262+
<divstyle="float:right;">
263+
<buttonclass="button is-danger"v-on:click="cancel">Cancel</button>
264+
</div>
265+
</div>
266+
</div>
267+
</div>
268+
</modal>
269+
217270
<!-- status output modal-->
218271
<modal:visible="statusOutputModal"class="modal-z-index"@close="closeStatusModal">
219272
<divclass="box statusModal">
@@ -268,11 +321,15 @@ export default {
268321
gitSuccess:false,
269322
gitCredentialsModal:false,
270323
gitWebHookModal:false,
324+
periodicalPipelineScheduleModal:false,
271325
gitBranches: [],
272326
giturl:'',
273327
pipelinename:'',
274328
pipelineNameSuccess:false,
275329
pipelineErrorMsg:'',
330+
periodicSchedules:'',
331+
periodicSchedulesErrMsg:'',
332+
periodicSchedulesErr:false,
276333
createPipeline: {
277334
id:'',
278335
output:'',
@@ -282,6 +339,7 @@ export default {
282339
pipeline: {
283340
name:'',
284341
type:'golang',
342+
perodicschedules: [],
285343
repo: {
286344
url:'',
287345
user:'',
@@ -491,6 +549,7 @@ export default {
491549
this.checkGitRepo()
492550
this.gitCredentialsModal=false
493551
this.gitWebHookModal=false
552+
this.periodicalPipelineScheduleModal=false
494553
this.$emit('close')
495554
},
496555
@@ -501,6 +560,7 @@ export default {
501560
this.createPipeline.pipeline.repo.privatekey.key=''
502561
this.createPipeline.pipeline.repo.privatekey.username=''
503562
this.createPipeline.pipeline.repo.privatekey.password=''
563+
this.periodicSchedules=''
504564
505565
this.close()
506566
},
@@ -513,6 +573,35 @@ export default {
513573
this.gitWebHookModal=true
514574
},
515575
576+
showPeriodicalPipelineScheduleModal () {
577+
this.periodicalPipelineScheduleModal=true
578+
},
579+
580+
addPeriodicalSchedules () {
581+
// Reset previous errors if there were some.
582+
this.periodicSchedulesErr=false
583+
584+
// Split string by line breaks.
585+
this.createPipeline.pipeline.periodicschedules=this.periodicSchedules.split('\n')
586+
587+
// Check if periodic schedule entries are valid.
588+
this.$http
589+
.post('/api/v1/pipeline/periodicschedules',this.createPipeline.pipeline.periodicschedules)
590+
.then(response=> {
591+
openNotification({
592+
title:'Periodic schedules valid',
593+
message:`All defined periodic schedules are valid!`,
594+
type:'success'
595+
})
596+
})
597+
.catch((error)=> {
598+
this.periodicSchedulesErr=true
599+
this.periodicSchedulesErrMsg=error.response.data
600+
})
601+
602+
this.close()
603+
},
604+
516605
showStatusOutputModal (msg) {
517606
if (!msg) {
518607
msg='No output found.'

‎frontend/client/views/settings/index.vue‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,22 @@
217217
</p>
218218
</div>
219219
</collapse-item>
220+
<collapse-itemtitle="Change Periodic Schedule">
221+
<divclass="pipeline-modal-content">
222+
<pclass="control">
223+
<textareaclass="textarea input-bar"v-model="pipelinePeriodicSchedules"></textarea>
224+
</p>
225+
<labelclass="label"style="test-align:left;">
226+
Use the standard cron syntax. For example to start the pipeline every half hour:
227+
<br />0 30 * * * *<br />
228+
Please see <ahref="https://godoc.org/github.com/robfig/cron"target="_blank">here</a> for more information.
229+
</label>
230+
</div>
231+
</collapse-item>
220232
</collapse>
221233
<divclass="modal-footer">
222234
<divstyle="float:left;">
223-
<buttonclass="button is-primary"v-on:click="changePipelineName">Change Name</button>
235+
<buttonclass="button is-primary"v-on:click="changePipeline">Accept changes</button>
224236
</div>
225237
<divstyle="float:right;">
226238
<buttonclass="button is-danger"v-on:click="close">Cancel</button>
@@ -333,7 +345,8 @@ export default {
333345
showDeleteUserModal:false,
334346
showAddUserModal:false,
335347
showEditPipelineModal:false,
336-
showDeletePipelineModal:false
348+
showDeletePipelineModal:false,
349+
pipelinePeriodicSchedules:''
337350
}
338351
},
339352
@@ -394,6 +407,11 @@ export default {
394407
},
395408
396409
editPipelineModal (pipeline) {
410+
// Check if periodic schedules is given.
411+
if (pipeline.periodicschedules) {
412+
this.pipelinePeriodicSchedules=pipeline.periodicschedules.join('\n')
413+
}
414+
397415
this.selectPipeline= pipeline
398416
this.showEditPipelineModal=true
399417
},
@@ -411,6 +429,7 @@ export default {
411429
this.showEditPipelineModal=false
412430
this.showDeletePipelineModal=false
413431
this.selectPipeline= {}
432+
this.pipelinePeriodicSchedules=''
414433
this.$emit('close')
415434
},
416435
@@ -518,7 +537,10 @@ export default {
518537
this.$router.push('/pipeline/create')
519538
},
520539
521-
changePipelineName () {
540+
changePipeline () {
541+
// Convert periodic schedules into list.
542+
this.selectPipeline.periodicschedules=this.pipelinePeriodicSchedules.split('\n')
543+
522544
this.$http
523545
.put('/api/v1/pipeline/'+this.selectPipeline.id,this.selectPipeline)
524546
.then(response=> {

‎gaia.go‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"time"
66

77
hclog"github.com/hashicorp/go-hclog"
8+
"github.com/robfig/cron"
89
)
910

1011
// PipelineType represents supported plugin types
@@ -110,16 +111,18 @@ type User struct {
110111

111112
// Pipeline represents a single pipeline
112113
typePipelinestruct {
113-
IDint`json:"id,omitempty"`
114-
Namestring`json:"name,omitempty"`
115-
RepoGitRepo`json:"repo,omitempty"`
116-
TypePipelineType`json:"type,omitempty"`
117-
ExecPathstring`json:"execpath,omitempty"`
118-
SHA256Sum []byte`json:"sha256sum,omitempty"`
119-
Jobs []Job`json:"jobs,omitempty"`
120-
Created time.Time`json:"created,omitempty"`
121-
UUIDstring`json:"uuid,omitempty"`
122-
IsNotValidbool`json:"notvalid,omitempty"`
114+
IDint`json:"id,omitempty"`
115+
Namestring`json:"name,omitempty"`
116+
RepoGitRepo`json:"repo,omitempty"`
117+
TypePipelineType`json:"type,omitempty"`
118+
ExecPathstring`json:"execpath,omitempty"`
119+
SHA256Sum []byte`json:"sha256sum,omitempty"`
120+
Jobs []Job`json:"jobs,omitempty"`
121+
Created time.Time`json:"created,omitempty"`
122+
UUIDstring`json:"uuid,omitempty"`
123+
IsNotValidbool`json:"notvalid,omitempty"`
124+
PeriodicSchedules []string`json:"periodicschedules,omitempty"`
125+
CronInst*cron.Cron`json:"-"`
123126
}
124127

125128
// GitRepo represents a single git repository
@@ -130,7 +133,7 @@ type GitRepo struct {
130133
PrivateKeyPrivateKey`json:"privatekey,omitempty"`
131134
SelectedBranchstring`json:"selectedbranch,omitempty"`
132135
Branches []string`json:"branches,omitempty"`
133-
LocalDeststring
136+
LocalDeststring`json:"-"`
134137
}
135138

136139
// Job represents a single job of a pipeline

‎handlers/handler.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func InitHandlers(e *echo.Echo) error {
6666
e.POST(p+"pipeline/:pipelineid/start",PipelineStart)
6767
e.GET(p+"pipeline/latest",PipelineGetAllWithLatestRun)
6868
e.POST(p+"pipeline/githook",GitWebHook)
69+
e.POST(p+"pipeline/periodicschedules",PipelineCheckPeriodicSchedules)
6970

7071
// PipelineRun
7172
e.POST(p+"pipelinerun/:pipelineid/:runid/stop",PipelineStop)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp