[error]Bash exited with code '1' - bad substitution in Azure YAML pipeline

9.9k Views Asked by At

I am trying to integrate storybook/chromatic into my azure pipeline, however i am getting the following error:

/home/vsts/work/_temp/60ae6370-8818-4ab7-a2d8-f4a0443fadf9.sh: line 1: --project-token=${project_token}: bad substitution

I followed this https://www.chromatic.com/docs/azure-pipelines

I did obviously put my project token where it was needed.

1

There are 1 best solutions below

0
On

Based on the error message, it seems that this issue comes from a script format or symbol.

I have tested the YAML sample from the link you shared and it can work fine.

Here are my steps, you can refer to them.

Step1 : Set the variable CHROMATIC_PROJECT_TOKEN

enter image description here

Step2: Run the YAML sample:

stages:
- stage: Test
  displayName: Chromatic Testing
  # Job list
  jobs:
  - job: Chromatic_Deploy
    displayName: Install packages and publishes to Chromatic

    steps:

    - task: NodeTool@0
      inputs:
        versionSpec: '12.x'
      displayName: 'Install Node.js'  
    - task: Npm@1
      inputs:
        command: 'install'
        workingDir: '$(build.sourcesdirectory)'

    - task: CmdLine@2
      displayName: Publish to Chromatic
      inputs:
        script: npx chromatic --project-token=${CHROMATIC_PROJECT_TOKEN}

Here is my result:

enter image description here

You can also try to use --project-token=$(CHROMATIC_PROJECT_TOKEN) in the YAML sample.