npm-version-test) on Jenkins using the Jenkins CLI. The job prints the installed Node.js and npm versions. We’ll download its XML configuration, adjust the build steps, and push the changes back.
Prerequisites
- Jenkins server accessible at
http://localhost:8080/ jenkins-cli.jardownloaded locally- CLI access via SSH; for example:
| Authentication Method | Command Example |
|---|---|
| HTTP | java -jar jenkins-cli.jar -s http://localhost:8080/ help |
| SSH | ssh -l siddharth -p 41397 localhost help |
1. Check Installed Node.js & npm
First, verify your local Node.js and npm versions:2. Download the Job Configuration
Fetch the existing job’s XML to a local file.2.1 Using HTTP
2.2 Using SSH
Always back up your existing XML before editing. You can keep a copy:
3. Inspect the Current Configuration
Opennpm-job.xml and locate the <builders> section. It should resemble:
4. Update the Build Steps
Modifynpm-job.xml so the shell step echoes a message and invokes both Node.js and npm versions. Replace the <builders> section with:
npm-job.xml.
5. Push the Updated Configuration
Send the modified XML back to Jenkins:5.1 Via SSH
5.2 Via HTTP
6. Verify Your Changes
- In the Jenkins UI, open npm-version-test.
-
Check that the build step now shows:
-
Trigger a new build. The console log should display something like: