How to run cypress tests in bitbucket piepline using environment variables

Viewed 25

I am new to setting up pipeline for running automation tests. I am using bitbucket pipleline to configure running Cypress tests against two environment - dev and qa. Locally I have created cypress.env.json file and passing all credentials for dev/qa environment. in spec file I am reading these values using Cypress.env() method. Locally it runs fine. Now to set bitbucket pipeline here what I did,

  1. Added pipeline
  2. Added environment variables as secured variables in deployment variables (assuming I can then have same variable name for dev and qa environments with different values)
  3. Issue: System is unable to read variables and hence tests failing due to missing environment variables.

Question: How do I set up environment details on pipeline so tests can run and pass value to Cypress.env()method.

Pipeline:

# This is an example Starter pipeline configuration
# Use a skeleton to build, test and deploy using manual and parallel steps
# -----
# You can specify a custom docker image from Docker Hub as your build environment.

image:  cypress/included:10.7.0
pipelines:
  branches:
    pipeline-update-hn:
   
          -  step:
                name: 'Run smartUi tests on Dev environment'
                deployment: dev
                script:
                  -  echo 'username' is $username'
                  -  npm ci
                  -  npm run cy:run:dev
                artifacts:
                  - cypress/screenshots/**
                  - cypress/videos/*
0 Answers
Related