limit pipelines by cron name, #2628
This commit is contained in:
parent
64d80a4a92
commit
e855881324
19 changed files with 70 additions and 0 deletions
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- update drone-runtime to version 1.0.5.
|
||||
- support for Gitea oauth2, by [@techknowlogick](https://github.com/techknowlogick). [#2622](https://github.com/drone/drone/pull/2622).
|
||||
- ping the docker daemon before starting the agent, by [@bradrydzewski](https://github.com/bradrydzewski). [#2495](https://github.com/drone/drone/issues/2495).
|
||||
- filter pipelines by cron job name, by [@bradrydzewski](https://github.com/bradrydzewski). [#2628](https://github.com/drone/drone/issues/2628).
|
||||
|
||||
## [1.0.1] - 2019-04-10
|
||||
### Added
|
||||
|
|
|
@ -43,6 +43,7 @@ type Build struct {
|
|||
AuthorAvatar string `db:"build_author_avatar" json:"author_avatar"`
|
||||
Sender string `db:"build_sender" json:"sender"`
|
||||
Params map[string]string `db:"build_params" json:"params,omitempty"`
|
||||
Cron string `db:"build_cron" json:"cron,omitempty"`
|
||||
Deploy string `db:"build_deploy" json:"deploy_to,omitempty"`
|
||||
Started int64 `db:"build_started" json:"started"`
|
||||
Finished int64 `db:"build_finished" json:"finished"`
|
||||
|
|
|
@ -48,6 +48,7 @@ type Hook struct {
|
|||
AuthorEmail string `json:"author_email"`
|
||||
AuthorAvatar string `json:"author_avatar"`
|
||||
Deployment string `json:"deploy_to"`
|
||||
Cron string `json:"cron"`
|
||||
Sender string `json:"sender"`
|
||||
Params map[string]string `json:"params"`
|
||||
}
|
||||
|
|
1
go.sum
1
go.sum
|
@ -63,6 +63,7 @@ github.com/drone/go-login v1.0.3 h1:YmZMUoWWd3QrgmobC1DcExFjW7w2ZEBO1R1VeeobIRU=
|
|||
github.com/drone/go-login v1.0.3/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
|
||||
github.com/drone/go-login v1.0.4-0.20190308175602-213d1719faed h1:Y0qiKFf6gsgTRTQS1roMh7kKVyrx+HSQmFsIgcZsHsM=
|
||||
github.com/drone/go-login v1.0.4-0.20190308175602-213d1719faed/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
|
||||
github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
|
||||
github.com/drone/go-scm v1.2.0 h1:ezb8xCvMHX99cSOf3WPI2bmYS6tDVTTap9BiPsPmmXg=
|
||||
github.com/drone/go-scm v1.2.0/go.mod h1:YT4FxQ3U/ltdCrBJR9B0tRpJ1bYA/PM3NyaLE/rYIvw=
|
||||
github.com/drone/go-scm v1.3.0 h1:XXg2X8GhSvJRr4RTu40t2o9XUa1WXK7BWzK0AVQHygM=
|
||||
|
|
|
@ -325,6 +325,7 @@ SELECT
|
|||
,build_author_avatar
|
||||
,build_sender
|
||||
,build_params
|
||||
,build_cron
|
||||
,build_deploy
|
||||
,build_started
|
||||
,build_finished
|
||||
|
@ -424,6 +425,7 @@ UPDATE builds SET
|
|||
,build_author_avatar = :build_author_avatar
|
||||
,build_sender = :build_sender
|
||||
,build_params = :build_params
|
||||
,build_cron = :build_cron
|
||||
,build_deploy = :build_deploy
|
||||
,build_started = :build_started
|
||||
,build_finished = :build_finished
|
||||
|
@ -459,6 +461,7 @@ INSERT INTO builds (
|
|||
,build_author_avatar
|
||||
,build_sender
|
||||
,build_params
|
||||
,build_cron
|
||||
,build_deploy
|
||||
,build_started
|
||||
,build_finished
|
||||
|
@ -490,6 +493,7 @@ INSERT INTO builds (
|
|||
,:build_author_avatar
|
||||
,:build_sender
|
||||
,:build_params
|
||||
,:build_cron
|
||||
,:build_deploy
|
||||
,:build_started
|
||||
,:build_finished
|
||||
|
|
|
@ -53,6 +53,7 @@ func toParams(build *core.Build) map[string]interface{} {
|
|||
"build_author_avatar": build.AuthorAvatar,
|
||||
"build_sender": build.Sender,
|
||||
"build_params": encodeParams(build.Params),
|
||||
"build_cron": build.Cron,
|
||||
"build_deploy": build.Deploy,
|
||||
"build_started": build.Started,
|
||||
"build_finished": build.Finished,
|
||||
|
@ -135,6 +136,7 @@ func scanRow(scanner db.Scanner, dest *core.Build) error {
|
|||
&dest.AuthorAvatar,
|
||||
&dest.Sender,
|
||||
¶msJSON,
|
||||
&dest.Cron,
|
||||
&dest.Deploy,
|
||||
&dest.Started,
|
||||
&dest.Finished,
|
||||
|
|
|
@ -300,6 +300,7 @@ const queryColsBulds = queryCols + `
|
|||
,build_author_avatar
|
||||
,build_sender
|
||||
,build_params
|
||||
,build_cron
|
||||
,build_deploy
|
||||
,build_started
|
||||
,build_finished
|
||||
|
|
|
@ -164,6 +164,7 @@ func scanRowBuild(scanner db.Scanner, dest *core.Repository) error {
|
|||
&build.AuthorAvatar,
|
||||
&build.Sender,
|
||||
&build.Params,
|
||||
&build.Cron,
|
||||
&build.Deploy,
|
||||
&build.Started,
|
||||
&build.Finished,
|
||||
|
|
|
@ -50,6 +50,7 @@ type nullBuild struct {
|
|||
AuthorAvatar sql.NullString
|
||||
Sender sql.NullString
|
||||
Params types.JSONText
|
||||
Cron sql.NullString
|
||||
Deploy sql.NullString
|
||||
Started sql.NullInt64
|
||||
Finished sql.NullInt64
|
||||
|
@ -88,6 +89,7 @@ func (b *nullBuild) value() *core.Build {
|
|||
AuthorAvatar: b.AuthorAvatar.String,
|
||||
Sender: b.Sender.String,
|
||||
Params: params,
|
||||
Cron: b.Cron.String,
|
||||
Deploy: b.Deploy.String,
|
||||
Started: b.Started.Int64,
|
||||
Finished: b.Finished.Int64,
|
||||
|
|
|
@ -116,6 +116,10 @@ var migrations = []struct {
|
|||
name: "create-table-nodes",
|
||||
stmt: createTableNodes,
|
||||
},
|
||||
{
|
||||
name: "alter-table-builds-add-column-cron",
|
||||
stmt: alterTableBuildsAddColumnCron,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -544,3 +548,11 @@ CREATE TABLE IF NOT EXISTS nodes (
|
|||
,UNIQUE(node_name)
|
||||
);
|
||||
`
|
||||
|
||||
//
|
||||
// 011_add_column_builds_cron.sql
|
||||
//
|
||||
|
||||
var alterTableBuildsAddColumnCron = `
|
||||
ALTER TABLE builds ADD COLUMN build_cron VARCHAR(50) NOT NULL DEFAULT '';
|
||||
`
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
-- name: alter-table-builds-add-column-cron
|
||||
|
||||
ALTER TABLE builds ADD COLUMN build_cron VARCHAR(50) NOT NULL DEFAULT '';
|
|
@ -112,6 +112,10 @@ var migrations = []struct {
|
|||
name: "create-table-nodes",
|
||||
stmt: createTableNodes,
|
||||
},
|
||||
{
|
||||
name: "alter-table-builds-add-column-cron",
|
||||
stmt: alterTableBuildsAddColumnCron,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -522,3 +526,11 @@ CREATE TABLE IF NOT EXISTS nodes (
|
|||
,UNIQUE(node_name)
|
||||
);
|
||||
`
|
||||
|
||||
//
|
||||
// 011_add_column_builds_cron.sql
|
||||
//
|
||||
|
||||
var alterTableBuildsAddColumnCron = `
|
||||
ALTER TABLE builds ADD COLUMN build_cron VARCHAR(50) NOT NULL DEFAULT '';
|
||||
`
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
-- name: alter-table-builds-add-column-cron
|
||||
|
||||
ALTER TABLE builds ADD COLUMN build_cron VARCHAR(50) NOT NULL DEFAULT '';
|
|
@ -112,6 +112,10 @@ var migrations = []struct {
|
|||
name: "create-table-nodes",
|
||||
stmt: createTableNodes,
|
||||
},
|
||||
{
|
||||
name: "alter-table-builds-add-column-cron",
|
||||
stmt: alterTableBuildsAddColumnCron,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -524,3 +528,11 @@ CREATE TABLE IF NOT EXISTS nodes (
|
|||
,UNIQUE(node_name)
|
||||
);
|
||||
`
|
||||
|
||||
//
|
||||
// 011_add_column_builds_cron.sql
|
||||
//
|
||||
|
||||
var alterTableBuildsAddColumnCron = `
|
||||
ALTER TABLE builds ADD COLUMN build_cron TEXT NOT NULL DEFAULT '';
|
||||
`
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
-- name: alter-table-builds-add-column-cron
|
||||
|
||||
ALTER TABLE builds ADD COLUMN build_cron TEXT NOT NULL DEFAULT '';
|
|
@ -155,6 +155,7 @@ func (s *Scheduler) run(ctx context.Context) error {
|
|||
AuthorName: commit.Author.Name,
|
||||
AuthorEmail: commit.Author.Email,
|
||||
AuthorAvatar: commit.Author.Avatar,
|
||||
Cron: job.Name,
|
||||
Sender: commit.Author.Login,
|
||||
}
|
||||
|
||||
|
|
|
@ -460,6 +460,7 @@ var (
|
|||
AuthorEmail: "octocat@hello-world.com",
|
||||
AuthorAvatar: "https://avatars3.githubusercontent.com/u/583231",
|
||||
Sender: "octocat",
|
||||
Cron: "nightly",
|
||||
Trigger: "@cron",
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,10 @@ func skipRepo(document *yaml.Pipeline, repo string) bool {
|
|||
return !document.Trigger.Repo.Match(repo)
|
||||
}
|
||||
|
||||
func skipCron(document *yaml.Pipeline, cron string) bool {
|
||||
return !document.Trigger.Cron.Match(cron)
|
||||
}
|
||||
|
||||
func skipMessage(hook *core.Hook) bool {
|
||||
switch {
|
||||
case hook.Event == core.EventTag:
|
||||
|
|
|
@ -178,6 +178,7 @@ func (t *triggerer) Trigger(ctx context.Context, repo *core.Repository, base *co
|
|||
AuthorEmail: base.AuthorEmail,
|
||||
AuthorAvatar: base.AuthorAvatar,
|
||||
Params: base.Params,
|
||||
Cron: base.Cron,
|
||||
Deploy: base.Deployment,
|
||||
Sender: base.Sender,
|
||||
Created: time.Now().Unix(),
|
||||
|
@ -268,6 +269,10 @@ func (t *triggerer) Trigger(ctx context.Context, repo *core.Repository, base *co
|
|||
logger = logger.WithField("pipeline", pipeline.Name)
|
||||
logger.Infoln("trigger: skipping pipeline, does not match deploy target")
|
||||
continue
|
||||
} else if skipCron(pipeline, base.Cron) {
|
||||
logger = logger.WithField("pipeline", pipeline.Name)
|
||||
logger.Infoln("trigger: skipping pipeline, does not match cron job")
|
||||
continue
|
||||
} else {
|
||||
matched = append(matched, pipeline)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue