Skip to content

Commit

Permalink
added jenkins ci/cd files
Browse files Browse the repository at this point in the history
  • Loading branch information
toschoch committed Dec 9, 2018
1 parent c92f47f commit 1f455d7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 34 deletions.
11 changes: 11 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node('docker') {
stage('Checkout') {
checkout scm
}
stage('UnitTest') {
docker.image('python:3-alpine').inside {
sh 'pip install requirements-dev.txt'
sh 'py.test'
}
}
}
34 changes: 0 additions & 34 deletions {{cookiecutter.project_slug}}/.drone.yml

This file was deleted.

48 changes: 48 additions & 0 deletions {{cookiecutter.project_slug}}/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
def gitVersion() {
desc = sh(script: "git describe --tags --long --dirty", returnStdout: true)?.trim()
parts = desc.split('-')
assert parts.size() in [3, 4]
dirty = (parts.size() == 4)
tag = parts[0]
count = parts[1]
sha = parts[2]
if (count == '0' && !dirty) {
return tag
}
return sprintf( '%1$s.dev%2$s+%3$s', [tag, count, sha.substring(1)])
}

def isTag() {
commit = getCommit()
if (commit) {
desc = sh(script: "git describe --tags --long ${commit}", returnStdout: true)?.trim()
match = desc =~ /.+-[0-9]+-g[0-9A-Fa-f]{6,}$/
result = !match
match = null
return result
}
return false
}
pipeline {
stages {
stage('Checkout') {
checkout scm
}

stage('Build Image') {
withCredentials([
usernamePassword(credentialsId: 'docker public',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD')]) {
def builtImage = docker.build("${USERNAME}/{{cookiecutter.project_slug}}")
}
}

stage('Push Image') {
when { tag "release-*" }
docker.withRegistry('https://hub.docker.com/','docker public') {
builtImage.push()
}
}
}
}

0 comments on commit 1f455d7

Please sign in to comment.