Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sepulchered
Last active November 15, 2023 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save sepulchered/2e97b29b2c3b95e0ee2501f7c6dcf037 to your computer and use it in GitHub Desktop.
Save sepulchered/2e97b29b2c3b95e0ee2501f7c6dcf037 to your computer and use it in GitHub Desktop.
Sample Jenkinsfile for node.js projects
#!/usr/bin/env groovy
pipeline {
agent any
environment {
NODE_ENV_PATH = './venv'
NODE_VERSION = '6.11.1'
}
stages {
stage('Pre-cleanup') {
steps {
sh 'rm -rf ./venv'
sh 'rm -rf ./node_modules'
sh 'rm -rf ./bower_components'
}
}
stage('Make venv') {
steps {
sh 'nodeenv --prebuilt -n $NODE_VERSION $NODE_ENV_PATH'
}
}
stage('Install dependencies') {
steps {
sh '. ./venv/bin/activate && npm install'
sh '. ./venv/bin/activate && npm install -g bower'
sh '. ./venv/bin/activate && bower install'
}
}
stage('Run tests') {
steps {
sh '. ./node_env/bin/activate && npm test'
}
}
}
post {
failure {
echo 'Processing failed'
}
success {
echo 'Processing succeeded'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment