Skip to content

Instantly share code, notes, and snippets.

@deskoh
Created November 3, 2019 09:02
Show Gist options
  • Select an option

  • Save deskoh/d85b8e9795c92aab4c9bf5277c6dc76d to your computer and use it in GitHub Desktop.

Select an option

Save deskoh/d85b8e9795c92aab4c9bf5277c6dc76d to your computer and use it in GitHub Desktop.
Jenkinsfile
pipeline {
agent none
stages {
stage('Checkout') {
agent {
docker { image 'node:alpine' }
}
stages {
stage('Install Dependencies') {
steps {
echo 'Installing dependencies...'
sh 'npm ci'
}
}
stage('Static Analysis') {
parallel {
stage('Lint') {
steps {
echo 'Linting...'
// catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
catchError {
sh 'npm run eslint -- -f checkstyle -o eslint.xml'
}
}
post {
always {
// Warnings Next Generation Plugin
recordIssues enabledForFailure: true, tools: [esLint(pattern: 'eslint.xml')]
}
}
}
stage('Typecheck') {
steps {
echo 'Type Checking...'
sh 'npx tsc -p . --noEmit'
}
}
}
}
stage('Build') {
environment {
NODE_ENV = 'production'
}
steps {
echo 'Building..'
sh 'npm run build'
}
}
}
}
stage('Integration Tests') {
// Use docker agent for integration test
agent { label 'docker' }
steps {
script {
docker.image('postgres:alpine').withRun('-e "POSTGRES_PASSWORD=password" -e "POSTGRES_DB=test"') {c ->
docker.image('node:alpine').inside("--link ${c.id}:db") {
// sh 'npm ci'
// sh 'npm run test'
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment