0

yml file:

image: node:latest

definitions:

yaml-anchors:
  - &aws-login
    oidc: true
    name: 'AWS login'
    script:
      - echo "Signing into aws..."
      - export REGION=us-east-1
      - export AWS_ROLE_ARN=arn:aws:iam::$NONPROD:role/SAccess
      - export WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token
      - echo $STEP_OIDC_TOKEN > $(pwd)/web-identity-token


  caches:
    pnpm: $BITBUCKET_CLONE_DIR/.pnpm-store
  steps:
    - step: &install-pnpm
        name: 'Install pnpm'
        script:
          - echo "Installing pnpm"
          - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
          - pnpm -v
        caches:
          - pnpm
    - step: &build
        name: 'Run Build'
        script:
          - echo "Running build..."
          - pnpm run build

pipelines:
  pull-requests:
    main:
      - step: *install-pnpm
      - step:
          name: 'Build and test apps on pull requests'
          caches:
            - pnpm
            - node
          script:
            - pnpm ci // Error here: `pnpm ci command not found`
            - npx nx workspace-lint

I have pipeline defined above which installs the pnpm via curl but fails to run pnpm ci command in pull-request step

Not sure what is issue here. Did find any docs on this issue.

I have pipeline defined above which installs the pnpm via curl but fails to run pnpm ci command in pull-request step

Not sure what is issue here. Did find any docs on this issue.

kittu
  • 6,662
  • 21
  • 91
  • 185

1 Answers1

1

Each step script happens in a new pristine docker container, so any tooling setup must happen in the same script where it will be used.

image: node:latest

definitions:
  caches:
    pnpm: $BITBUCKET_CLONE_DIR/.pnpm-store

  yaml-anchors:
    - &install-pnpm-script >-
        curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@

    - &build-step
        name: 'Run Build'
        script:
          - echo "Running build..."
          - pnpm run build

pipelines:
  pull-requests:
    main:
      - step:
          name: 'Build and test apps on pull requests'
          caches:
            - pnpm
            - node
          script:
            - *install-pnpm-script
            - pnpm ci
            - npx nx workspace-lint
N1ngu
  • 2,862
  • 17
  • 35
  • What is `>-` in `&install-pnpm-script` anchor? – kittu Oct 28 '22 at 04:39
  • 1
    It starts a scalar block. Check out https://yaml-multiline.info/ – N1ngu Oct 28 '22 at 07:57
  • Getting error: There is an error in your bitbucket-pipelines.yml at [pipelines > branches > ** > 1 > step > script > 0]. To be precise: Missing or empty command string. Each item in this list should either be a single command string or a map defining a pipe invocation. – kittu Nov 01 '22 at 16:33
  • Updated the question. Please check – kittu Nov 01 '22 at 16:41