Reputation: 5367
In the quick start guide of Azure DevOps Services for npm it states in the last Step 6: Publish an npm package the following:
"If you have npmjs.com configured as an upstream and the package name/version exists in the public registry then you will be blocked from publication"
In other words, once a build using an Azure pipeline starts, and you'd like it to build a package, it will only build a package once a package version is used which doesn't exist.
However, trying to do so will result in a warning resulting in an orange/yellow build status.
Is it possible to check whether or not a package version is updated so that the build only tries to build a package if the package version actually contains a new version? Or is there another method that is recommended here?
Upvotes: 2
Views: 3064
Reputation: 1929
There are three steps here:
- script: |
PackageName=$(npm list --json --depth=0 | sed -n 2p | cut -d '"' -f4)
NewPackageVersion=$(npm list --json --depth=0 | sed -n 3p | cut -d '"' -f4)
PublishedPackageVersion=$(npm show $PackageName version)
echo "##vso[task.setvariable variable=NewPackageVersion;]$NewPackageVersion"
echo "##vso[task.setvariable variable=PublishedPackageVersion;]$PublishedPackageVersion"
displayName: "Extract package versions"
- task: Npm@1
inputs:
command: publish
displayName: "Publish"
condition: |
and(
ne(variables['NewPackageVersion'], variables['PublishedPackageVersion']),
succeeded(),
eq(variables['Build.SourceBranch'], 'refs/heads/master')
)
Upvotes: 7
Reputation: 30372
The behavior is expected as it doesn't support overriding packages that exist on the public registry.
Is it possible to check whether or not a package version is updated so that the build only tries to build a package if the package version actually contains a new version?
Theoretically speaking it should be possible, you can try writing a script to check that first, if the specific version not existing in public registry then build and publish, otherwise stop the build. However if there are large amount of data to be compared, then it will consume long time for the building... even encounter timeout issues...
Upvotes: 0