-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
67 lines (64 loc) · 2.21 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pipeline {
agent any
parameters {
string(name: 'TAG', defaultValue: '', description: 'Docker tag')
string(name: 'CORE_VERSION', defaultValue: '', description: 'MicroDocs Core version')
string(name: 'CLI_VERSION', defaultValue: '', description: 'MicroDocs ClI version')
}
stages {
stage("Checkout") {
steps {
deleteDir()
checkout scm
stash name: 'source'
}
}
stage('Build microdocs-server') {
steps {
unstash name: 'source'
dir('microdocs-server') {
sh "node -p -e \"var fs = require('fs'); var pJson = require('./package.json'); pJson.dependencies['@maxxton/microdocs-core'] = '${env.CORE_VERSION}'; fs.writeFileSync('./package.json', JSON.stringify(pJson));\""
sh 'npm install'
sh 'npm version ' + env.TAG
sh 'npm run test'
sh 'npm run prepublish'
sh 'cp .npmrc dist/.npmrc'
dir('dist') {
sh 'npm install --prod'
stash name: 'server-dist'
}
}
}
}
stage('Build microdocs-ui') {
steps {
unstash name: 'source'
dir('microdocs-ui') {
sh "node -p -e \"var fs = require('fs'); var pJson = require('./package.json'); pJson.dependencies['@maxxton/microdocs-core'] = '${env.CORE_VERSION}'; fs.writeFileSync('./package.json', JSON.stringify(pJson));\""
sh 'npm install'
sh 'npm version ' + env.TAG
sh './node_modules/.bin/ng build --prod'
dir('dist') {
stash name: 'ui-dist'
}
}
}
}
stage('Build docker image') {
steps {
unstash name: 'source'
unstash name: 'server-dist'
unstash name: 'ui-dist'
sh 'docker build --tag=maxxton/microdocs:' + env.TAG + ' --no-cache --build-arg=CLI_VERSION=' + env.CLI_VERSION + ' .'
}
}
stage('Public docker image') {
steps {
sh 'docker login --email $DOCKERHUB_EMAIL --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASSWORD'
sh 'docker push maxxton/microdocs:' + env.TAG;
sh 'docker tag maxxton/microdocs:' + env.TAG + ' maxxton/microdocs:latest'
sh 'docker push maxxton/microdocs:latest'
}
}
}
}