Commit ce2a8000 authored by Muhammad Tehami's avatar Muhammad Tehami 💡

Jenkinsfile added

parent 89512509
stage 'CI'
node {
checkout scm
//git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
dir('solitaire-javascript') {
// pull dependencies from npm
// on windows use: bat 'npm install'
sh 'npm install'
// stash code & dependencies to expedite subsequent testing
// and ensure same code & dependencies are used throughout the pipeline
// stash is a temporary archive
stash name: 'everything',
excludes: 'test-results/**'
includes: '**'
// test with PhantomJS for "fast" "generic" results
// on windows use: bat 'npm run test-single-run -- --browsers PhantomJS'
sh 'npm run test-single-run -- --browsers PhantomJS'
}
// archive karma test results (karma is configured to export junit xml files)
step([$class: 'JUnitResultArchiver',
testResults: 'solitaire-javascript/test-results/**/test-results.xml'])
}
stage 'Browser Testing'
parallel chrome: {
runTests("Chrome")
}, firefox: {
runTests("Firefox")
}
def runTests(browser) {
node {
// on windows use: bat 'del /S /Q *'
sh 'rm -rf *'
unstash 'everything'
dir('solitaire-javascript') {
// on windows use: bat "npm run test-single-run -- --browsers ${browser}"
sh "npm run test-single-run -- --browsers ${browser}"
}
sh 'ls'
step([$class: 'JUnitResultArchiver',
testResults: 'test-results/**/test-results.xml'])
}
}
stage name: 'Deploy to staging', concurrency: 1
input 'Deploy to staging?'
node {
// write build number to index page so we can see this update
// on windows use: bat "echo '<h1>${env.BUILD_DISPLAY_NAME}</h1>' >> app/index.html"
sh "echo '<h1>${env.BUILD_DISPLAY_NAME}</h1>' >> app/index.html"
// deploy to a docker container mapped to port 3000
// on windows use: bat 'docker-compose up -d --build'
sh 'docker-compose up -d --build'
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment