We’re using the gradle node plugin to build our node project from gradle. The gitlab ci template we chose uses the gradle:alpine docker image. In our job we run the gradle wrapper. The build fails with “env: can’t execute ‘node’: No such file or directory”. It builds fine on our linux dev box.
Here is the stack trace:
Caused by: java.io.IOException: Cannot run program "/builds/myueser/myproj/.gradle/nodejs/node-v10.11.0-linux-x64/bin/node" (in directory "/builds/myueser/myproj"): error=2, No such file or directory at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25) ... 6 more Caused by: java.io.IOException: error=2, No such file or directory
Here are the pertinent contents from the gitlab-ci.yml:
image: gradle:alpine
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
GIT_STRATEGY: clone
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- export PATH=`pwd`/.gradle/nodejs/node-v10.11.0-linux-x64/bin:$PATH
deploy-ui:
stage: deploy
script: ./gradlew --build-cache assemble deploymyprojWeb --debug
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
Also, the following is from the build.gradle file:
plugins {
id "com.moowork.node" version "1.2.0"
id 'com.adarshr.test-logger' version '1.5.0'
}
apply plugin: "java"
apply plugin: "groovy"
repositories {
jcenter()
}
dependencies {
testCompile(
'junit:junit:4.12',
'org.codehaus.groovy:groovy-all:2.4.15',
'org.spockframework:spock-core:1.1-groovy-2.4',
gradleTestKit()
)
}
node {
version = '10.11.0'
download = true
}
npm_install {
args = ["$project.projectDir/myproj", '--prefix',"$project.projectDir/myproj"]
}
task deploymyprojWeb(type: NpmTask) {
args = ['run','deploy', '--prefix',"$project.projectDir/myproj"]
}
deploymyprojWeb.dependsOn npm_install
wrapper {
gradleVersion = '4.10.2' //version required
}
Content of node distribution folder (/builds/myuser/myproj/.gradle/nodejs/node-v10.11.0-linux-x64/bin):
/builds/myuser/myproj/.gradle/nodejs/node-v10.11.0-linux-x64/bin/npx Exec: true Write: true Read: true /builds/myuser/myproj/.gradle/nodejs/node-v10.11.0-linux-x64/bin/node Exec: true Write: true Read: true /builds/myuser/myproj/.gradle/nodejs/node-v10.11.0-linux-x64/bin/npm Exec: true Write: true Read: true