Reputation: 245
I have several jobs on Jenkins for launch protractor tests. I'm starting to use async
/await
at some points and seems that the default version of Node.js that has Jenkins doesn't handle async
/await
.
I prepared a workaround on another pipeline that uses async
/await
, but I don't want to use it as a default solution:
nodejs(nodeJSInstallationName: "Node 8.11") {
"npm config ls"
"node -v"
"npm"
}
How can I setup the desired version Node.js, which will be used by Jenkins by default?
Upvotes: 13
Views: 42403
Reputation: 997
Go to: Dashboard → Manage Jenkins → Global Tool Configuration → NodeJS and pick the desired Node.js version from the combobox.
Upvotes: 11
Reputation: 21
Just use the following two lines in your pipeline
env.NODEJS_HOME = "${tool 'NodeJsv12.16.2'}"
env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}"
See the example bellow
node {
env.NODEJS_HOME = "${tool 'NodeJsv12.16.2'}"
env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}"
sh 'npm --version'
stage('Preparation') {
}
}
Upvotes: 0