jenkins error: The NODE_ENV variable is not set. Defaulting to a blank string

8/30/2021

i have shell script written in jenkins and refering secrets through keybase. in docker compose yaml file i have declared environment variable to define branch like staging production and dev. also have seperate start.sh file for 3 branches when i build them getting above mentioned error and im not able to access service through postman.

like i have start_prd.sh content as below

docker-compose stop
docker-compose build
NODE_ENV=production docker-compose up -d

and docker compose yaml file as below

version: "3"

services:
  gdsp-liftandlearn-service:
    restart: always
    container_name: gdsp-liftandlearn-service
    image: node:14
    user: "node"
    networks:
      gdsp-net:
        ipv4_address: 172.27.0.10
    working_dir: /home/node/app
    environment:
      - NODE_ENV=${NODE_ENV}
    volumes:
      - "/home/ubuntu/gdsp-liftandlearn-service:/home/node/app"
    expose:
      - "3001"
    command: "npm start"

networks:
  gdsp-net:
    external: true
-- Anil Kumar Atchi
bitbucket
docker
docker-compose
jenkins
kubernetes

0 Answers