Skip to content

Commit

Permalink
ci(openshift): Add a stage to deploy docs to prod and publish the npm…
Browse files Browse the repository at this point in the history
… package.
  • Loading branch information
ryanoglesby08 committed Aug 1, 2017
1 parent fa61ee7 commit 90fbb41
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
46 changes: 34 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ try {
)
}

stage('User Input') {
inputUrl = env.BUILD_URL ? "(${env.BUILD_URL}input)" : '';
stage('Deploy Prod Trigger') {
inputUrl = env.BUILD_URL ? "(${env.BUILD_URL}deploy-prod-trigger)" : '';
notifyBuild(
message: "Build is ready for Production ${inputUrl}",
color: '#0000FF',
Expand All @@ -72,17 +72,32 @@ try {
}
}

// No deploy to production yet... :)
stage('Deploy Production') {
deploy(
buildVersion: buildVersion,
environment: 'production',
numReplicas: 1
)
}

stage('Publish Trigger') {
inputUrl = env.BUILD_URL ? "(${env.BUILD_URL}publish-trigger)" : '';
notifyBuild(
message: "Build is ready for a Publish ${inputUrl}",
color: '#0000FF',
buildVersion: buildVersion
)
timeout(time:1, unit:'DAYS') {
input 'Publish the npm package?'
}
}

// stage('Deploy Production') {
// deploy(
// buildVersion: buildVersion,
// environment: 'production',
// uiNewRelicId: '24442164',
// bffNewRelicId: '24534533',
// numReplicas: 3
// )
// }
stage('Publish') {
publish(
name: 'tds',
buildVersion: buildVersion
)
}

currentBuild.result = 'SUCCESS'
}
Expand Down Expand Up @@ -173,6 +188,13 @@ def deploy(Map attrs) {
}
}

def publish(Map attrs) {
node {
unstash 'scripts'
sh("./openshift/run-publish.sh ${attrs.name} ${attrs.buildVersion}")
}
}

def notifyBuild(Map attrs) {
node {
slackSend(
Expand Down
24 changes: 24 additions & 0 deletions openshift/run-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

## Runs `npm publish` against a container on OpenShift. Used by the Release stage of the Jenkinsfile.
## Usage: ./run-publish.sh tds latest

NAME=${1}
VERSION=${2:-latest}
IMAGESTREAM=`oc get imagestream ${NAME} -o='jsonpath={.status.dockerImageRepository}'`

oc run ${NAME}-${VERSION} \
--image=${IMAGESTREAM}:${VERSION} \
--rm=true \
--attach=true \
--restart=Never \
--overrides='{
"apiVersion":"v1",
"spec":{
"containers":[{
"name": "'${NAME}'-'${VERSION}'",
"image": "'${IMAGESTREAM}':'${VERSION}'",
"command":["npm", "publish", "--access=public"]
}]
}
}'

0 comments on commit 90fbb41

Please sign in to comment.