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

yaml triggers doc #1383

wants to merge 5 commits into from

Conversation

ericsciple
Copy link
Contributor

No description provided.

exclude: []

schedules:
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


builds:
- name: otherDefinition
ci: true # Simple build trigger
Copy link
Contributor

Choose a reason for hiding this comment

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

lets use the "trigger" keyword instead of CI consistently.

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.

```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.


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.

exclude: []
paths:
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.

paths:
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.

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.

- 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.

- 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.

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 :)

@mmitche
Copy link
Member

mmitche commented Jan 29, 2018

Some other things that appear missing:

  • PR/Push specific jobs - How can I specify that a job is run on commit, vs. one run on PR?
  • PR contexts - How can I specify that a PR job will show up in the UI (Github or otherwise) as "Release Build and test" or "Code Coverage build and test"
  • Optional jobs - How can I specify triggers are that optional? e.g. a job that runs the outerloop tests, but isn't run automatically?

@ericsciple
Copy link
Contributor Author

@mmitche this triggers doc does not cover PR triggers (I need to update the doc, although we are targeting rolling out CI support first).

You can setup PR on the definition in the web today. You can add conditions to the phases so they only run on a PR versus a CI. build.reason is a variable that you can use in your condition. Here is a doc about phase conditions using variables. And here is an example definition. Ping me if it's easier to discuss offline.

@chcosta
Copy link

chcosta commented Jan 29, 2018

build.reason == nice, I'm glad there is now support for this.

@mmitche
Copy link
Member

mmitche commented Jan 29, 2018

@ericsciple Sounds good. Just to confirm, you are planning on supporting PR triggers in the files in the near term, it's just not yet in the design.

@chrispat
Copy link
Contributor

@mmitche yes we plan to do that just have not designed yet.

@mmitche
Copy link
Member

mmitche commented Feb 7, 2018

@chrisrpatterson One other thing came up. It would be really ideal if the triggers could launch the jobs with specified parameters. This allow more code sharing. For instance, recently we've had issues with our official product build testing. We launch full builds overnight and would like to schedule one with testing on, and one with testing off. But the current triggers only launch with the defaults. In both the yaml and web interface world, that really only leaves you with the option of cloning the file/definition, which is non-ideal.

@mmitche
Copy link
Member

mmitche commented Feb 20, 2018

@chrisrpatterson Any comment on the triggers with non-default parameters?

@ericsciple
Copy link
Contributor Author

I split this into two PRs. One that is just for CI trigger features that are in master of VSTS. And this one, will track trigger features that aren't implemented yet.

@chrispat chrispat added the Design label Mar 6, 2018

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.

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

## Schedules (future; needs cleanup)

```yaml
schedules:
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?

@jtpetty
Copy link
Contributor

jtpetty commented Oct 9, 2019

@vtbassmatt - Can you take a look at this one?

@vtbassmatt vtbassmatt closed this Oct 9, 2019
@vtbassmatt vtbassmatt deleted the users/ersciple/m130triggers branch October 9, 2019 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants