Can't find installed dependencies in Docker container in Jenkins

Viewed 460

I have a setup which spins a docker container in Jenkins and after that I want to run some commands in relation to the installed packages.In this example we try to lint the project via eslint. eslint is in package.json so it should be installed when running yarn install. I've wasted a lot of time to solve this so any help resolving this is much appreciated

Jenkins file

pipeline {
    agent {
     label 'linux'
    }

    stage('Test') {
      agent {
        dockerfile {
            filename 'Dockerfile.builder'
            dir '.'
        }
      }
      steps {
        sh label: '', script: 'yarn lint'
      }
    }
}

Dockerfile.builder

FROM node:14.17.4-alpine

WORKDIR /tools

COPY yarn.lock ./
COPY package.json ./

RUN yarn install --pure-lockfile && yarn cache clean

COPY . ./

Errors

warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
warning Skipping preferred cache folder "/.cache/yarn" because it is not writable.
warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-1500".
warning Cannot find a suitable global folder. Tried these: "/usr/local, /.yarn"
/bin/sh: eslint: not found
0 Answers
Related