Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,421
Community Members
 
Community Events
184
Community Groups

package.json files field is ignored in Bitbucket npm publish pipeline

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?

1 answer

1 accepted

0 votes
Answer accepted
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 30, 2022

@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

Mladen Oršolić
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Apr 08, 2023 • edited

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 :

  branches:
    production:
      - parallel:
        - step:
            name: Build and Test
            caches:
              - node
            script:
              - npm install
              - npm run rollup
              - npm test
            artifacts:
              - dist/**                                       <<< the artifacts part



Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events