1
votes

I am in the process of setting up Azure Pipelines to build and publish an Angular project containing some libraries that we have developed, but I am having some issues understanding some parts of it, particularly triggering the release pipeline to build and publish the libraries. I've been reading this guide for tips on how to set it up.

Build pipeline(s)

Currently the Angular project contains two libraries. I have created two build pipelines that installs the library's dependencies, builds one of the libraries, respectively, archives the build folder, and publishes the archive to $(Build.ArtifactStagingDirectory). As I understand it, that should make it available to the build pipeline. Nothing else has been done in the build pipeline(s).

Build pipeline image

Release pipeline

Next, I have created a release pipeline. On the pipeline, I added an artifact, set the source type to Build, and picked one of the build pipelines. I enabled Continuous deployment trigger on the artifact, and set a build branch filter of refs/tags/v*, since I was experimenting with building from tags.

Then, on the stage, I added an Extract files task with destination folder set to $(System.DefaultWorkingDirectory)\extracted. After that, I added an npm task with Command set to publish and Working folder that contains package.json set to $(System.DefaultWorkingDirectory)\extracted, and registry to an Azure Artifacts feed.

Release pipeline image

Triggering a build

As noted above, the release pipeline doesn't trigger if I add a tag to the repository.

What I've tried

I tried changing the CD trigger on the artifact in the release pipeline to the master branch and committing to the branch, but this did not trigger the release pipeline either.

If I run the build pipeline manually, the release pipeline runs, but fails with the error

error enoent ENOENT: no such file or directory, open 'D:\a\r1\a\extracted\package.json'

But this just seems to be a misunderstanding on my part on where the published archive ends up.

What I'd like to happen

For the release pipeline to run when I add a version tag to the repository.

The best solution for me would be if I could publish the two libraries in the Angular project with different version numbers, but this I am not sure how to do, at least not if I would use tags to trigger releases (the tag would be e.g. v0.0.1 and thus not make sense if one library is at version 0.0.3 and the other at 0.0.1).

The second-best option is if I can publish both libraries and simply have them keep identical version numbers.

Any help and tips is appreciated. If any info is missing, please let me know.

Edit - Solution

I guess I misunderstood how the triggers on release pipelines function.

The missing piece was adding a trigger on the build pipeline for tags. For designer-based builds, it was not clear to me that this could be done since you are just shown the branches in a dropdown in the branch filter on the triggers for a build pipeline, but you can simply type refs/tags/v* into the Filter my branches field, and hit enter (also shown in the image below).

Build pipeline trigger image

Credit to @JukkaK for this.

1

1 Answers

0
votes

For builds, see the update at the bottom of this blog post:

https://edsnider.net/2018/11/14/detecting-git-tag-pushes-in-azure-devops.html

Not sure how that'd work with build designer if you're unable to use yaml-based builds, but I'd give a simple "v*" or "refs/tags/*" a go. If those don't work with the designer, one way to circumvent the problem might be tagging the build (perhaps with https://marketplace.visualstudio.com/items?itemName=colinsalmcorner.colinsalmcorner-buildtasks) with condition:

and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))

And then triggering the release based on the tags