We use a self-hosted Azure DevOps server for our private npm packages.
We've had success using Azure Pipelines to build and deploy packages to Azure Artifacts. This works fine but I and my colleagues can still publish from the npm command npm publish.
Can anyone tell me how to publish packages only from Azure pipelines and prevent users to publish from their development machine ?
Please check this official doc:
https://learn.microsoft.com/en-us/azure/devops/artifacts/feeds/feed-permissions?view=azure-devops#permissions-table
You need to set permission in this place:
Related
I am trying to publish a npm package with Yarn to a private Artifactory registry. This registry does not require a login. So I do not need to provide any auth. When I set the registry to my local registry, I am able to publish successfully. I.E:
yarn publish
However, when I try to do this same operation in non-interactive mode, I receive a 403 forbidden response from the registry. I.E:
yarn publish --non-interactive
Why does this work with interactive mode but non-interactive mode? I am building a CI-CD pipeline, so I really need this work in non-interactive mode.
I have tried to modify my .yarnrc files, set the registry at the command line, and add the registry to my package json.
Using private registry in connection with IBM Cloud DevOps pipeline, we've got
modules published. In DevOps pipeline also build is possible using following tactic:
#!/bin/bash
export PATH=/opt/IBM/node-v6.7.0/bin:$PATH
npm config set #<scope>:registry <registry-url>
echo "//<registry-url-short>:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm install
This way both public and private modules are found and installed. However, when it comes time to deploy to NodeJS runtime, then 'npm install' is done on platform side.
How can we instruct that with above ?
Another approach is to package your .npmrc file along with your app when you push it. More info here https://github.com/cloudfoundry/nodejs-buildpack/issues/79
The approach here is to create a .npmrc as part of your build stage and add it to the root of your artifact folder. In the next stage when you deploy the app from the artifact folder your npm configuration will be correctly set for per-project config (see https://docs.npmjs.com/files/npmrc) and the npm install that the cf node build-pack performs will work correctly.
One possible way is to have your private modules downloaded in a different directory using the postinstall script in npm. Here is a good explanation on how to achieve this.
https://github.com/pmuellr/bluemix-private-packages
I have this bitbucket-pipelines.yml, is there any way to copy the build that is created by npm run buid into my repository?
image: node:6.9.4
pipelines:
branches:
master:
- step:
caches:
- node
script:
- npm install
- npm run build
If you mean saving the build as a Download in your Bitbucket repository, then we have a guide on how to do it via the Bitbucket API. The basic steps are:
Create an app password for the repository owner
Create a Pipelines environment variable with the authentication token
Upload your artifacts to Bitbucket Downloads using curl and the Bitbucket REST API
The details of how to do this are covered in the guide.
If you mean committing the build back to the Git repository, we wouldn't recommend that. Storing build output in Git isn't ideal - you should use BB downloads or an npm registry for that. But if you really want to, you can do it by following the guide above to create an app password, then pass it as an environment variable into Pipelines, set it in a HTTPS git remote, then use git push to upload it back to Bitbucket.
I'm using azure cloud service with Web & Worker Role and Angular4. How can deploy package without node_modules and run NPM install command after complete deployment. Is there any way?
Now I can deploy from VSTS to azure, but I can't run npm after deploy is successful.
Now it is work like -> run npm install for branch files => zip => copy to azure => deploy.
I want to add npm run custom-comand to end of this chain.
How to do it?
The Azure App Service Deployment task in VSTS now supports a post-deployment script. Here is a screen-shot from version 3.* of the task:
See Task Parameters for more details.
Windows App Services users: Watch out for an npm bug that prevents multiple npm commands from being run (inline or in a script). For example:
npm install
npm test
Will only run npm install. There are several workarounds including this:
npm install & npm test
There is no out of box build task to achieve the feature you want. If you do want to run the npm from Azure App Service:
Manually: You can go to Kudu console of the App Service and run npm command there:
Automatically: You need to create your own build task to run the npm command via Kudu Rest API
You can run commands like npm install via the Kudu REST API.
Here's a scripted example written in PowerShell.
Add a PowerShell script task after the Azure App Service Deploy task to invoke npm install (or any other command that Kudu supports). And disable the npm install task in your build pipeline.
The Kudu deployment engine that App Service leverages has the ability to run custom deployment scripts. You can include your desired npm command inside of a custom deployment script that will be executed as part of the deployment on Azure's side. No REST API calls required and everything stays in your source control system.
You can use PowerShell task or npm task to execute npm commands .
One thing to note: you also need to upload the .npmrc with auth token to Azure.