I have created a private npm package which is published to Azure Artifacts. To publish my npm package I have a npm publish step in my tfs build definition. I am using tfs version 16.131.28507.4
.
This all works as intented. However, if a build is triggered where the npm package version is unchanged the npm publish will fail with a 403
forbidden. This error causes the rest of my build to fail. The npm package is part of a larger project, so it will not be uncommon for builds to occur where the npm package is unchanged.
Is it possible to prevent the tfs build step which performs the npm publish
from running if the current version within my packages feed is the same as the version specified within the package json?
I aware of the "Custom Conditions" within the build step, but am unsure how to link the Azure Artifacts current published version with the version in my package.json
. I am also aware of the "Continue on Error" option within the build definition, but this creates a partially succeeded build which I would like to avoid in this case.
If a build is triggered where the npm package version is unchanged the npm publish will fail with a 403 forbidden.
That's an expected behavior. Since your package name/version not changed. A package with that name was already published before, so you'd need to use a different name in your package.json
file and then npm publish again.
In your case, the simplest solution one is updating your minimum version of npm package even nothing changed. Another as you have pointed out, using "Continue on Error" option within the build definition, but this creates a partially succeeded build.
We do not have any build-in settings/configurations with Azure Artifacts or npm task could judge if the current version within your packages feed is the same as the version specified within the package json.
And for customer conditions, we also do not provide such an expression that controls when this task should run. For this, you could take a look at this official link--Conditions.
Another workaround should be separating your build pipeline, one for build something, npm publish package. One for build something, refer your npm package in azure package feed. If you want each time npm version changed auto trigger second build. You could use Trigger Build Task to chain the build.