Closed straurob closed 4 years ago
Update 1
For further debugging I ran the following commands inside the Gradle Dokcer container on the Jenkins host:
sh './gradlew clean vaadinPrepareNode build'
sh '/var/lib/jenkins/workspace/build-mokka-app/gradle/node/node /var/lib/jenkins/workspace/build-mokka-app/gradle/node/node_modules/npm/bin/npm-cli.js --no-update-notifier install'
This gives me the following error message:
npm WARN no-name@ No repository field.
npm ERR! path /.npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/.npm'
npm ERR! { [Error: EACCES: permission denied, mkdir '/.npm']
npm ERR! stack: 'Error: EACCES: permission denied, mkdir \'/.npm\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/.npm' }
npm ERR!
As you can see, the npm directory to be used is /.npm
whereas the build expects the path to be /var/lib/jenkins/workspace/build-mokka-app/gradle/node/node_modules/npm
.
Hi! Thank you so much for debugging of the issue. In my case the .npm
folder is created in $HOME
. Could you please check what is value of $HOME
in the docker image? My guess is that it's empty, but it's good to have it confirmed first.
Could you please check what is value of $HOME in the docker image? My guess is that it's empty, but it's good to have it confirmed first.
When running echo $HOME
in the docker.image command then $HOME
points to /
.
If i change the args to -u root -v ${HOME}/.m2:/maven/.m2
, i.e. the container is started as root, then $HOME points to /root
.
Here's a screenshot of the Jenkins workspace. As you can see there are several folders owned by root
. I guess that might be a problem.
Hi, yeah, it also sounds like a permission/user problem to me. It seems that the files are checked out by the jenkins
user, however gradle seem to be running under the root
user? :thinking: However that can't be right, since root user would definitely be able to create the /.npm
folder... Could it be that the Vaadin plugin launches npm not as root, but as some other user perhaps?
Could you perhaps run gradle with --debug --stacktrace, perhaps we can learn more about why the npm failed?
Regardless, the Vaadin Gradle plugin should definitely dump stderr of the npm subprocess if it crashes, instead of just printing that it exited with non-zero exit code. I'll try to play with this a bit.
After having searched for similiar issues I stumbled across this workaround. This works for me at the moment :slightly_smiling_face:
docker.image(gradleDockerImage).inside("${gradleDockerArgs}") {
withEnv([
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
'npm_config_cache=npm-cache',
/* set home to our current directory because other bower
* nonsense breaks with HOME=/, e.g.:
* EACCES: permission denied, mkdir '/.config'
*/
'HOME=.',
]) {
sh 'gradle clean vaadinPrepareNode build -Pvaadin.productionMode'
sh "mkdir -p ${gradleDependencyPath} && (cd ${gradleDependencyPath}; jar -xf ../libs/*.jar)"
}
}
Thank you for letting us know and for posting of the workaround. This looks like a permission issue. The plugin 0.14.3.7 and 0.17.x should now correctly dump stderr, closing as fixed.
Desktop (please complete the following information):
Describe the bug When building my app with Jenkins the build fails with a "missing dependency error". The app stack is Spring boot 2.2.5 with Vaadin 14.
To Reproduce
Expected behavior The build should finish successfully.
Additional context
Jenkins Console Output
build.gradle
Jenkinsfile