Exclude file types in CI triggers on Azure Devops Pipelines Builds - azure-devops

I'm having trouble with setting up a build where commits with only changes to markdown files do not trigger the build.
On the build, I have continuous integration enabled with "include" branch filters.
To exclude changes to markdown files I setup a single "exclude" path filters to **/*.md, which from my understanding of file matching patterns should recursively match all files that end in .md. However, when I push just a change to a markdown file, the build is still triggered.
I considered adding an "include" path filter with /, but the builds are still being triggered without it.
How do I specify specify to not build when only a certain file type was changed?

As of now, wild cards are not supported for these file path filters.
You're going to be forced into a different convention to bypass the trigger for these files.
Putting .md files in an explicit structure (ex: /docs) that you can exclude with the "pattern" given in the examples you linked exclude: docs/.
Illustration:
Given:
(repo)
\src
|\d1
| \md
|
\d2
\md
The following does not trigger on changes to either /md directory.
trigger:
branches:
include:
- master
paths:
include:
- /src/**/md/
The following always triggers on changes under src/, even for files in both .../md directories.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/**/md/
The following triggers on changes under src/, src/d1/, src/d2, .../d2/md but not for any changes under src/d1/md/.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/
This same behavior holds true for your specific desire to try and call out a group of files using *.md.
Given each directory has a [variant]_README.md file in it, the following is true:
CI is triggered
when changes are made to src/d1/md/f1_README.md
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/*.md
CI is triggered
when changes are made to src/d1/md/f1_README.md
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/*README.md
CI is triggered
when changes are made to src/d1/md/f1_README.md or any other .md file.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- /**/*.md
CI is triggered
when changes are made to src/d1/md/f1_README.md or any other .md file.
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- /*.md
CI is NOT triggered
when changes are made to src/d1/md/f1_README.md
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- src/d1/md/f1_README.md

The newest update from 08/09/2021 made possible to use wild cards in path filter.
Wild cards can be used when specifying inclusion and exclusion branches for CI or PR triggers in a pipeline YAML file. However, they cannot be used when specifying path filters. For instance, you cannot include all paths that match src/app//myapp*. This has been pointed out as an inconvenience by several customers. This update fills this gap. Now, you can use wild card characters (, *, or ?) when specifying path filters.
So now it should be possible to ave triggers as follows:
trigger:
branches:
include:
- master
paths:
include:
- src/
exclude:
- /**/*.md

Related

How to get a build triggered only for pattern specified in the GitRepo resource in JFrog Pipelines?

The files include, exclude regex for a GitRepo resource are getting ignored. This is the resource definition I’ve created:
- name: platform_pr
type: GitRepo
configuration:
gitProvider: myGithub
path: dev/helm-values
files:
include: ^templates\/(pipelines)\/*.+$
branches:
include: ^master$
buildOn:
commit: false
pullRequestCreate: true
tagCreate: false
cancelPendingRunsOn:
newCommit: false
pullRequestUpdate: true
I don't want the build to be triggered when PR has files in that specific folder. This is not woking as expected.
I see that in your yml you have specifically disabled builds for a commit: commit: false.
Unfortunately this files inclusion or exclusion filter only applies to commit events, and not pull requests, tags, or releases:
Please refer to this documentation of GitRepo Resource for more information.

Azure DevOps Pipeline Resource.Repository Trigger is not working

I have two repos named Project1 and Project2 with two branches main & dev and my default branch is main.
I have one build pipeline for Project1 named project1pipeline, it will be triggered by the main & dev branches. I added Project2 as resources.repositories.repository code in the YAML file of Project1. Whenever the commit happened in both of the repos of the main(default branch), it triggers the project1pipeline
When I commit some changes in the dev branch of the Project1 repo, it triggers the project1pipeline but When I commit some changes in the dev branch of the Project2 repo, it doesn't trigger project1pipeline.
Project1 YAML file for the main branch
trigger:
branches:
include:
- main
pool:
name: default
resources:
repositories:
- repository: proj2
type: git
name: DevOps/Project2
ref : 'refs/heads/main'
trigger:
branches:
include:
- main
workspace:
clean: all
steps:
- checkout: self
clean: true
- checkout: proj2
clean: true
- task: CopyFiles#2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.txt'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
Project1 YAML file for the dev branch
trigger:
branches:
include:
- dev
pool:
name: default
resources:
repositories:
- repository: proj2
type: git
name: DevOps-Test/Project2
ref : 'refs/heads/dev'
trigger:
branches:
include:
- dev
workspace:
clean: all
steps:
- checkout: self
clean: true
- checkout: proj2
clean: true
- task: CopyFiles#2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.txt'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
Note: Both the repo in the same project
This is an expected behavior in Azure Pipeline with resource trigger.
From my test result, the branch resource trigger works corresponding with the default branch set for Project1. Current default branch is main.
Here is the test process:
Project1 dev:
Project1 main:
The pipeline using this .yml file will be triggered by commit from:
-Project1 dev
-Project1 main
-Project2 main
Refer to this official doc:https://learn.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=schema
If you change Project1 default branch to dev.
The pipeline using this .yml file will be triggered by commit from:
-Project1 dev
-Project1 main
-Project2 dev

GitHub Action errors because it can't see a folder

I'm trying to set up my first GiHub Action. All it needs to do is run a test over my Godot files. I based it on a template.
name: CI
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: godot-tester
uses: croconut/godot-tester#v2.5
with:
version: 3.4
release_type: stable
# Give relative path to your project.godot, if not in top level of repo
path: app
The action errors every time, when trying to find the project file.
/entrypoint.sh: line 166: cd: ./app: No such file or directory
The folder, app, is there and it contains the project. I've tried with or without a trailing slash, it makes no difference.
When you need to access the files from the proper repository in a Github Actions workflow, you need to setup the actions/checkout first.
This will allow the workflow to access the Github workspace (which is basically the repository root).
In your case, the workflow should look like this:
name: CI
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: godot-tester
uses: croconut/godot-tester#v2.5
with:
version: 3.4
release_type: stable
# Give relative path to your project.godot, if not in top level of repo
path: app
The actions/checkout action has a default behavior, but you can also configure other fields to customize what you want it to do. Check the action README page to see all the possibilities.

Github include md files in README.md?

Is there a way in Github to include md files in for example the README.md?
# Headline
Text
[include](File:load_another_md_file_here.md)
It should not link to the file, it should load the contents from it, like PHP include / file_get_contents.
That does not seem to be possible, especially when considering github/markup#346 and github/markup#172.
No include directive is supported.
This is not the correct answer but a workaround for others who really want this.
It's possible to use Gulp and Gulp Concat to merge the files into one before they are sent to Github..
Since it is not possible I just ended up placing a link as
[MY-LINK](../../SOME-OTHER-README.MD)
migrate your readme to a different file then construct your actual README however you like as a github action
EDIT: Here's a demo that you can build off of. This repo has a single github action that runs a script that dynamically builds the README.md based on the contents of the repository (to build a site map for the repo in the form of a table of contents): https://github.com/dmarx/bench-warmers
the workflow config:
name: update-readme
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-python#v2
- name: Run the script
run: python scripts/update_readme.py
- name: Commit files
run: |
git config --local user.name "dmarx"
git add README.md
git commit -m "Updated TOC"
- name: Push changes
uses: ad-m/github-push-action#master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
Here's the chunk of my update script that's relevant to you:
... # code that builds the object `toc_str`
# template readme
with open('README.stub') as f:
readme_stub = f.read()
# simple replacement, use whatever stand-in value is useful for you.
readme = readme_stub.replace('{TOC}',toc_str)
with open('README.md','w') as f:
f.write(readme)
Which assumes you have a file named README.stub which might look something like this:
# Title
some text
{TOC}
more text
Where {TOC} is the substitution target for our dynamic content.
Ruby gem markdown_helper implements include files for GitHub flavored markdown (GFM).
Disclosure: I wrote the gem.

How to deploy to github with file pattern on travis?

I have created a simple travis configuration which packages an app and tries to deploy the archive file to github.
The problem is, I would like to have the version number part of the file name, so i require to use a pattern for the filename. I simply can't get it to work.
Configuration is currently:
deploy:
provider: releases
file: "build/distributions/worktrail-app-hub-sync*.zip"
on:
repo: worktrail/worktrail-app-hub-sync
tags: true
all_branches: true
But it fails with: "/home/travis/.rvm/gems/ruby-1.9.3-p547/gems/octokit-3.3.1/lib/octokit/client/releases.rb:86:in `initialize': No such file or directory - build/distributions/worktrail-app-hub-sync*.zip (Errno::ENOENT)" - but the file is certainly there: build/distributions/worktrail-app-hub-sync-0.0.1.zip
Example run: https://travis-ci.org/worktrail/worktrail-app-hub-sync/builds/35704111
travis.yml: https://github.com/worktrail/worktrail-app-hub-sync/blob/0.0.1/.travis.yml
Is this supported by travis deployment, or is there any workaround for this use case?
Wildcards are supported by now if you enable the file_glob option. This is how I deploy a build .deb file to GitHub releases:
before_deploy:
- export RELEASE_PKG_FILE=$(ls *.deb)
- echo "deploying $RELEASE_PKG_FILE to GitHub releases"
deploy:
provider: releases
api_key:
secure: YOUR_ENCRYPTED_API_KEY
file_glob: true
file: "${RELEASE_PKG_FILE}"
on:
tags: true
Setting up is easy by executing travis setup releases with a dummy filename and modifying .travis.yml afterwards.
deploy:
file_glob: true
file: "build/distributions/worktrail-app-hub-sync*.zip"
example
Sorry, wildcard patterns don't work at the moment, but we'll have a look into making that possible on Travis CI.