Last active
August 16, 2017 12:35
-
-
Save tnolet/78b7c9f54020ada56dd4f1ceac6cd9d1 to your computer and use it in GitHub Desktop.
vamp+dcos+jenkins guide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!groovy | |
node { | |
def nodeHome = tool name: '8.3.0', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation' | |
env.PATH = "${nodeHome}/bin:${env.PATH}" | |
// !! Replace these with your own settings !! | |
def gitRepo = 'https://github.com/magneticio/simpleservice/' | |
def dockerHub = 'https://registry.hub.docker.com' | |
def dockerHubCreds = 'docker-hub-login' | |
def dockerRepo = 'magneticio' | |
def dockerImageName = 'simpleservice' | |
def vampDeploymentName = 'simpleservice' | |
def vampHost = 'http://10.0.1.134:3232' | |
def appVersion | |
def dockerImage | |
currentBuild.result = "SUCCESS" | |
try { | |
stage('Checkout'){ | |
git url: gitRepo, branch: 'master' | |
appVersion = sh ( | |
script: 'node -p -e "require(\'./package.json\').version"', | |
returnStdout: true | |
).trim() | |
} | |
stage('Install') { | |
sh 'npm install' | |
} | |
stage('Test') { | |
sh 'npm test' | |
} | |
stage('Build Docker image') { | |
dockerImage = docker.build("${dockerRepo}/${dockerImageName}") | |
} | |
stage('Push Docker image') { | |
docker.withRegistry(dockerHub, dockerHubCreds) { | |
dockerImage.push(appVersion) | |
dockerImage.push("latest") | |
} | |
} | |
stage('Deploy to Vamp') { | |
sh "curl -X POST --data-binary @vamp_blueprint.yml ${vampHost}/api/v1/blueprints -H 'Content-Type: application/x-yaml'" | |
sh "curl -X PUT --data-binary @vamp_blueprint.yml ${vampHost}/api/v1/deployments/${vampDeploymentName} -H 'Content-Type: application/x-yaml'" | |
} | |
stage('Cleanup') { | |
sh 'rm node_modules -rf' | |
} | |
} | |
catch (err) { | |
currentBuild.result = "FAILURE" | |
throw err | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment