Is there an easy way how I can use an Azure DevOps pipeline, for example to build microservices (golang monorepo (after i tried single repos)) or my own libraries after a change, which then trigger another pipeline from another service that uses them?
For example the structure is like
|- Service1
|--- pipeline1.yml
|- Service2
|--- pipeline2.yml
|- libraries
|--- libraries1
|--- libraries2
|--- pipelinelibraries.yml
So, pipeline1 and pipeline2 look almost the same. A few parameters are different and both still use a template. After changes to the services, only these individual pipelines are triggered. e.g. (just small example, this already works)
trigger:
paths:
include:
- 'pathTO/service1/*'
parameters:
- name: name
....
- and so on
stages:
- template: ../template.yml #e.g. build stage
parameters:
name: xxx
...
But if now one Service is using lib1, and there are changes at lib1, how can i run/build the Libs pipeline and after that the service using the librarie which had changes? Is this possible? e.g. (first get triggered and then try wit jobs to trigger other?)
trigger:
paths:
include:
- 'libs/*'
jobs:
- job: buildIt
steps:
- ...
I hope I was able to describe it clearly?
As you can already read above, my individual pipelines work and I tried to create another one for e.g. my libraries. I then tried to build the changed library (or all libraries) and then using a job to trigger the services that use the library in which something was changed. so that change can be attracted immediately. However, that didn't work. I also googled it because I thought it's definitely not something that only I want to do (which I still assume). But somehow I couldn't find anything that would have helped me.
You should use the pipeline resource trigger.
It will allow you trigger the second pipeline on the completion first.
First pipeline
trigger:
paths:
include:
- 'libs/*'
jobs:
- job: buildIt
steps:
- ...
And the second pipeline:
trigger:
paths:
include:
- 'pathTO/service1/*'
parameters:
- name: name
....
- and so on
resources:
pipelines:
- pipeline: lib # Name of the pipeline resource.
source: lib-ci # The name of the pipeline referenced by this pipeline resource.
project: FabrikamProject # Required only if the source pipeline is in another project
trigger: true # Run thie pipeline when any run of lib-ci completes
stages:
- template: ../template.yml #e.g. build stage
parameters:
name: xxx
...