Trying to publish to private npm repo from bitbucket. The bundle is built and added to a folder called dist.
image: node:14
pipelines:
default:
- parallel:
- step:
name: Build and Test
caches:
- node
script:
- npm install
- npm test
- step:
name: Lint the node package
script:
- npm install eslint
- npx eslint .
caches:
- node
branches:
master:
- parallel:
- step:
name: Build and Test
caches:
- node
script:
- npm install
- npm run build
- step:
name: Security Scan
script:
# Run a security scan for sensitive data.
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
- pipe: atlassian/git-secrets-scan:0.5.1
- step:
name: Deploy to Production
deployment: Production
script:
# Bump versions before publishing
- npm --no-git-tag-version version "2.0.$BITBUCKET_BUILD_NUMBER" -m "Upgrade to new version"
# Publish package
- pipe: atlassian/npm-publish:0.3.2
variables:
NPM_TOKEN: $NPM_TOKEN
Problem is that publishing to npm, dist folder is not published.
Folder structure after building (locally and expected)
- package-name
- dist
- index.ts
- package.json
But with the Bitbucket pipeline, only package.json is added to the package, and dist is ignored.
Inside package.json, I've added the property
"files": [
"dist"
]
According to npm docs , files always take precedence over gitignore and npmrc.
Verified with npm publish --dry-run locally to make sure the right files are built. And it is working fine in that case.
I was able to make it work by adding entries in npmignore files (not adding dist in npmignore and adding in gitignore). But this creates a lot of redundancy.
Will Bitbucket pipeline consider files attribute in package.json?
@Justin George hi.Thanks for question. Try to use folder parameter according to the docs:
script: - pipe: atlassian/npm-publish:0.3.2 variables: NPM_TOKEN: $NPM_TOKEN FOLDER: 'dist'
Regards, Igor
Needed a few changes to get this working.
- Used artifacts to retain the dist folder
- used LOCAL_PATH instead of FOLDER
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
would you post a whole example pleae, not sure what would artifacts part look like
EDIT:
figured it out, and if it'll help anyone else :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.