Skip to content

Commit

Permalink
Merge pull request #5 from dcos-labs/danielmschmidt/DCOS-21772-add-ci-cd
Browse files Browse the repository at this point in the history
DCOS-21772: add CI/CD
  • Loading branch information
weblancaster authored Mar 27, 2018
2 parents 86808c4 + 841365d commit cfe651a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:8.9.4-alpine

# For deploying the gh-pages
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh

ENV CI true
COPY package*.json ./
RUN npm install --ignore-scripts

COPY . .
EXPOSE 6006
CMD ["npm", "start"]

77 changes: 77 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env groovy

@Library('sec_ci_libs@v2-latest') _

def master_branches = ["master", ] as String[]

pipeline {
agent {
dockerfile {
args '--shm-size=2g'
}
}

environment {
JENKINS_VERSION = 'yes'
}

options {
timeout(time: 1, unit: 'HOURS')
}

stages {
stage('Authorization') {
steps {
user_is_authorized(master_branches, '8b793652-f26a-422f-a9ba-0d1e47eb9d89', '#frontend-dev')
}
}

stage('Initialization') {
steps {
ansiColor('xterm') {
retry(2) {
sh '''npm install'''
}
}
}
}

stage('Unit Test') {
steps {
ansiColor('xterm') {
sh '''npm run test'''
}
}
}

stage('Build') {
steps {
ansiColor('xterm') {
sh '''npm run dist'''
}
}

post {
always {
archiveArtifacts 'dist/*'
}
}
}

stage('Deploy'){
when {
expression { env.BRANCH_NAME == 'master' }
}

steps {
// we need to do this workaround as jenkins clones without .git/ directory
sh '''rm -rf ui-kit && git clone https://github.com/dcos-labs/ui-kit.git && cd ui-kit && npm install'''
withCredentials([
string(credentialsId: '1f0a31fe-30eb-11e8-b467-0ed5f89f718b', variable: 'GITHUB_TOKEN')
]) {
sh '''cd ui-kit && npm run deploy:storybook -- --ci --host-token-env-variable=GITHUB_TOKEN'''
}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"preinstall": "./scripts/pre-install",
"start": "NODE_ENV=development npm run storybook --root ./ ",
"dist": "npm run clean && NODE_ENV=production webpack -p --config ./webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "echo \"TODO: specify tests\" && exit 0",
"commitlint": "commitlint -e",
"storybook": "start-storybook -p 6006",
"build:storybook": "build-storybook",
Expand Down

0 comments on commit cfe651a

Please sign in to comment.