I'm new to Docker/Jenkins.
Jenkins triggers the container via
docker run -t -d -u 995:315 -w /workspace/projectname -v /workspace/projectname:/workspace/projectname:rw,z -v /workspace/projectname@tmp:/workspace/projectname@tmp:rw,z circleci/node:latest
My Pipeline
pipeline {
agent {
docker {
image 'circleci/node:latest'
}
}
environment {
HOME="."
NPM_CONFIG_PREFIX="${pwd()}/.npm-global"
PATH="$PATH:${pwd()}/.npm-global/bin:${pwd tmp: true}/.npm-global/bin"
}
stages {
stage('NPM Config') {
steps {
sh 'npm install -g @angular/cli'
echo "PATH is: $PATH"
sh '.npm-global/bin/ng version'
sh '/workspace/projectname/.npm-global/bin/ng version'
sh 'ng version'
}
}
}
}
echo "PATH is: $PATH"
prints out
PATH is: /sbin:/usr/sbin:/bin:/usr/bin;/usr/bin/;/etc/;/etc/ssh/ssh/:/workspace/projectname/.npm-global/bin:/workspace/projectname@tmp/.npm-global/bin
Both of these
sh '.npm-global/bin/ng version'
sh '/workspace/projectname/.npm-global/bin/ng version'
do what I expect sh 'ng version'
to do. However, sh 'ng version'
gives me the following error
ng version
/workspace/projectname@tmp/durable-9f9bc04a/script.sh: 2: /workspace/projectname@tmp/durable-9f9bc04a/script.sh: ng: not found
I'm trying to avoid having to build my own image, what would be a good next step?
Also I would just use npx
, but I would need to change a lot of repos and their scripts just to make this work and I would prefer to not do that.
UPDATE: It looks like the pipeline is ignoring changes the the PATH environment variable under
environment {
HOME="."
NPM_CONFIG_PREFIX="${pwd()}/.npm-global"
PATH="/foo/bar"
}
Is there a special may to modify the PATH? or maybe a permission issue?