Last active
November 15, 2023 10:25
-
-
Save sepulchered/2e97b29b2c3b95e0ee2501f7c6dcf037 to your computer and use it in GitHub Desktop.
Sample Jenkinsfile for node.js projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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