Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml triggers doc #1383

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions docs/preview/yamlgettingstarted-authz.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

## Create definition on push

The ability to create a definition on push, is currently only supported for Git repos in VSTS.
The ability to create a definition on push, is currently only supported for Git repositories in VSTS.

The ability to create a definition on-push is currently only supported for Git repos in the
same VSTS team project as the build definition. The ability to create a definition from a push,
requires whoever pushes the commit to have authorization to create a definition.
The build definition will be created in the same VSTS team project. Whoever pushes the commit must
be authorized to create a definition.

For details about creating a definition on-push, refer [here](yamlgettingstarted-definition.md).

Expand All @@ -26,10 +25,10 @@ when saving the definition using the web UI or REST API.

The ability to authorize resources on push, is currently only supported for Git repos in VSTS.

This feature is only supported for pushes to the file `.vsts-ci.yml` in the root of the repo,
and in the default branch (specified on the repo options in source control). A push to the file
will cause the definition to be updated. When the YAML file is changed, the person who pushed
the branch update is considered to be the person updating the definition (regardless of commit author).
This feature is only supported for pushes to the file `.vsts-ci.yml` in the root of the repo.
A push to the file will cause the definition to be updated. When the YAML file is changed, the
person who pushed the branch update is considered to be the person updating the definition
(regardless of commit author).

Note, resource authorization is currently append only. Removing a resource from the YAML
file will not remove it's authorized status. A future update will provide a way to
Expand Down
6 changes: 3 additions & 3 deletions docs/preview/yamlgettingstarted-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

## When using a Git repo in your VSTS team project

Push a YAML file `.vsts-ci.yml` to the default branch (typically master) in the root
of your repository. A definition `<REPO_NAME>/<REPO_NAME> CI` will be created with a
continuous integration trigger for the default branch.
Push a YAML file `.vsts-ci.yml` to the root directory of your repository. A definition
`<REPO_NAME>/<REPO_NAME> CI` will be created, and a CI build will be triggered.

Note, the definition will only be created if whoever pushes the branch update has
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if someone without permissions were to push? Is there a process by which authorization could be given after the push?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if someone with permission pushes an update to the file. I'll clarify in master.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there is a way to authorize after the push. We need to figure out a way to make this better with GitHub as we do not have the VSTS user context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisrpatterson Can you use the github user info in that case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without some other mapping stored in VSTS we don't know that a given GitHub user actually has permissions in VSTS.

permission to create a definition.
Expand All @@ -21,6 +20,7 @@ located anywhere within your repo.

```yaml
queue: Hosted VS2017

steps:
- script: echo hello world
```
Expand Down
96 changes: 96 additions & 0 deletions docs/preview/yamlgettingstarted-triggers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# YAML getting started - YAML triggers (not yet available, for discussion only)

## Simple CI trigger syntax

On push, the YAML file from the branch that was updated, is used to determine whether
to queue a CI build.

For example, if master is updated, the trigger defined in master will be used. If a different
branch is updated, the YAML file from that branch will be used to determine whether to queue a
build.

```yaml
trigger:
- master
- releases/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so clarify here...if I push this to master (release branches don't exist yet), then the master's version of the yaml file will be used upon pushes to master. If I create a release/1.0 branch, then the release branch's version of the yaml file would be used on push to release/1.0.

What happens if I decide that pushes should happen on..say....dev/foobar? Can I do this simply by adding an entry for dev/foobar in the dev/foobar branch, or does the 'default' branch need to specify all the tracked branches?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes most sense for the triggers to be the 'union' of all branch's trigger sets, minus the opt out set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI triggers will actually be the set that is defined in the version of the file for the particular branch. So in the case of /refs/heads/dev/foobar a push there would get no build because it is not specified as included. I could then update the file in the dev/foobar branch to include dev/* and the next push to dev/foobar would start building. However, if I then took a branch from master before the change from dev/foobar was merged for dev/foobaz a push there would not build as that branch is not yet specified.

So the set of branches is not a union across all branches, it is only the set specified in the version of the file read for the particular commit.

```

## CI is opt-out

When not specified, the default trigger for build would be all branches.

For build this behavior makes sense. Especially when we start supporting on-push defintion creation from any branch. And on-push resource authorization from any branch.

For release, CI trigger would likely be opt-in? However with YAML, release will be tightly coupled with a repository. So opt-out CI behavior might also make sense for release? Or opt-out, but the default for RM only includes master?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about whether it should be opt-in/out. One thing to note is that release branches are often merged into other branches (especially master) as servicing fixes are created. This means yaml files are merged around a lot. Mistakenly enabling CI for a branch because of a merge is probably not a big deal, but mistakenly enabling release might be more significant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we are talking about the VSTS Release project not specifically release branches.

We have been discussing if the absence of any specified trigger pattern should mean trigger on all branches by default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For release, it can be opt-out provided the resource authorization is per branch.


```yaml
trigger: false | none # Turn off CI
```

## Full CI trigger syntax

```yaml
trigger:
batch: bool | number
branches:
include: []
exclude: []
paths:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example of paths trigger might be useful, I certainly imagine it will see a fair bit of use. Does it include standard globbing syntax?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They syntax is not as complete as the globbing syntax, it is a basic starts with and wild card at the end.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a path filter be used without a branch filter? According to current build UI, its not possible.
If same limitation applies to YAML, please document it :)

include: []
exclude: []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the rules of include/exclude across branches?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above the include/exclude is whatever is defined in the version of the file from the commit that triggered the build.

```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would allow for a custom expression here, one that could utilize the incoming CI metadata. Examples:

- customExpression: eq(Commiter, 'specialized-ci-bot')
- customExpression: contains(CommitMessage, 'test everything')
- customExpression: not(CommitMessage, 'skip ci')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmitche that is a good idea.


## Schedules (future; needs cleanup)

```yaml
schedules:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay, but I would allow for a cron string too. This is pretty common in the OSS world and has a lot of useful shortcuts. They also allow for 'star syntax', which means that times will randomly get picked. This causes workloads to be spread evenly over the day or hour. This is very useful for triggers that run often. Examples:

@daily - Runs every day at some point (same point every day)
@hourly - Runs every hour, at some point in the hour (same point every hour)
0 0 10 ? * 6L - Fires at 10:00 the last friday of every month.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have discussed CRON at the moment the job scheduler in VSTS does not support that syntax so we would have to do something custom. We have talked about ideas and maybe we could support a CRON like syntax but not necessarily everything right away.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be any support for specifying a variable value on a certain schedule? ie, if you wanted to provide a perf property to a build scheduled weekly or just build debug once a week or something like that?

- schedule: name
whenUnchanged: bool
Copy link
Contributor

@chrispat chrispat Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schedules are an array of individual schedules.

schedules:
- schedule
   whenUnchanged: bool
   days:
   time: # we could probably take the time and time zone info as a singe string hh:mmTZD
   timeZone:
   branches:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops i thought i had it that way

days: # Also supports a string instead of an array: "<DAY>" or "All" or "Weekdays"
- sun
- mon
- tues
- wed
- thurs
- fri
- sat
timeZone: EST # Defaults to account time zone? Do we know that info? We might need to maintain a mapping for this abbrev, it is not in system.timeZoneInfo.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way you could reference a default value for an entire collection so that you could easily ensure everyone is using the same time zone? ie, I don't care what the timezone is, I just want it to be consistent with the rest of devdiv.visualstudio.com

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort of goes into a general templating thing...I could define a standard dotnet core template for periodic builds, supply a parameter or two for specific info, and have the template take care of time/zone. e.g.

- standardNetCorePeriodicBuild([monday, friday])

Which goes to:

- schedules:
  - 1:00am
- whenUnchanged: true
- timeZone: PST
- days:
  - <parameter from input on standardNetCorePeriodicBuild>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, templating would be one way. something like -timeZone: $(ProjectCollection.TimeZone) is another, though that could be in a template as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default not specifying a timeZone is going to use the timeZone configured for your account.

Yes templating is also something we need to look at here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisrpatterson We were talking about overall build tooling (e.g. msbuild tasks) today, and versioning these build tools comes up a lot. We version them today through the use of nuget packages. I would be interested to know what kind of thoughts you have on versioning templates. It would be great if templates and other product tooling could be treated similarly (e.g. nuget packages that projects pull updates to as needed)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmitche lets take this topic discussion to a separate thread.

times:
- 03:00 am
- 03:00 pm
branches:
include: []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the branch rules here? What happens if the branches are empty? What happens if I specify 'master' in master and 'master, release/1.0' in the my release branch. What happens if I specify release/1.0 in my dev branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we have been discussing if we should treat schedules a bit differently than CI. Our thought is that the schedules are read form the repos default branch instead of trying to track and merge across all branches in a repo. In that model you would need to specify all schedules for all branches in master.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisrpatterson That is a bit odd though, since you have to alter process in one branch (in the target branch for the schedule), but policy (scheduling) in another.

My thought would be that the schedule would be read from the target branch, just like CI. Since updating the branch policy is a commit, VSTS would notice the commit, update the schedule for that branch if necessary, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, however, a branch can be a pattern like releases/* so if I have specified in master to run releases/* every day at 3 and then in one of the release branches I change releases/* to once a week who wins?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch wins in that case. What I see here is that by specifying as many branches as you want in a single definition, you're improving the mergeability of these files across branches. However, as a general rule, I think if the process (what needs to be done) comes from the branch itself, then the policy (when it needs to be done) should also be in that branch.

exclude: []
```

## Triggers on resources (future)

```yaml
resources:
repositories:
- name: tools
trigger: # Need a property to hang trigger info on
branches:
include: []
exclude: []
# ...polling, etc

builds:
- name: otherDefinition
trigger: true # Simple build trigger

- name: otherDefinition2
trigger: # Build trigger with branch/tag filters
branches:
include:
- releases/*
exclude: []
tags:
include: []
exclude: []

packages:
- name: somePackage
feed: someFeed
trigger: true # Packages too
```
2 changes: 2 additions & 0 deletions docs/preview/yamlgettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ YAML builds require the latest agent. When a YAML build is queued, your agent wi

[Multiple phases](yamlgettingstarted-phases.md)

[Triggers](yamlgettingstarted-triggers.md)

## Misc

[Resource authorization](yamlgettingstarted-authz.md)
Expand Down