packge.json not found while executing on Jenkins My Dockerfile looks something like this.

FROM mhart/alpine-node:8.11.3

RUN mkdir -p /app
COPY ./ /app

WORKDIR /app/build

RUN yarn global add serve
CMD ["serve", "-l", "3000"]

EXPOSE 3000


And then JenkinsFile looks something like this.

 node {
  try {

    stage('Checkout source code') {
        checkout scm
    }

    stage('Install packages') {
      sh("docker run --rm -v `pwd`:/app -w /app node yarn install")
      //sh("sudo chown -R jenkins: ./node_modules")
    }

    stage('Set the enviroment variables') {
      sh("echo set-env-variables")
      }

    stage('Build static assets') {

      sh("docker run --rm -v `pwd`:/app -w /app node yarn build")
    }
  }}


When I do run it on Jenkins,the console output says error Couldn't find a package.json file in "/app" and also it gives an error sudo not found even though I have added Jenkins ALL=(ALL) NOPASSWD: ALL to /etc/sudoers file.

I run the commands listed in my Jenkinsfile on my terminal and they all work fine but when i run them on Jenkins , they dont work.
Because you are setting the container's WORKDIR to /app/build so your package.json is not in the working directory, but in the parent of the working directory.