Hello All,
I am trying to figure out how to setup more than one build for my git hub repository. I would like to have 3 builds
- A manual build that does a release and pushes the resulting nuget to my private feed
- A build that is triggered when there is a delivery to my master branch (deploys a different nuget)
- A build that is triggered by a delivery to any branch that has a pull request
I do not see how to add different builds for a repo in the web browser. Do I have to add logic to my .yml file to get these different builds? Any guidance on this is appreciated
This looks like a job for™ conditional build and conditional deployment:
if: branch = master OR type = pull_request OR tag IS present
<...>
deploy:
on:
condition: "$TRAVIS_BRANCH" == "master" || -n "$TRAVIS_TAG"
<...>
The “manual build” will be triggered by tagging the commit. Alternatively, you can trigger it manually via UI or API – then you’ll need to set some other indicator in the custom config like an envvar and replace the tag conditions appropriately.
Thanks for the help. i think my biggest problem is that I can’t find adequate documentation on the syntax of the .yml file (as i figured this logic could be done in the .yml file initially just can’t figure out exactly how). I tried adding the if: as you mentioned. Basically just a test to list the files in TRAVIS_BUILD_DIR if I’m building off master (see below). Seems that is not right as it did not even build in Travis. Can you point me to some documentation that describes the syntax of the .yml file. Or maybe some .yml that has an example of how to do this?
My .yml:
sudo: required
language: csharp
mono: none
dotnet: 2.0.0
script:
- dotnet restore ./src/MySolution.sln
- dotnet msbuild ./src/MySolution.sln
if: branch = master
- find $TRAVIS_BUILD_DIR
A YAML file is not a program. Its top level represents a hash table (like JSON), so the order of the keys is not significant (and is actually undefined in the data structure that it’s parsed into).
As such, if:
is not a conditional block. As per the linked article, it rather sets a condition when the entire build should be triggered.