added jenkinsfile for CI
This commit is contained in:
parent
2ff0b7fa9f
commit
d2acdf4a91
47
Jenkinsfile
vendored
Normal file
47
Jenkinsfile
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
def label = "node-${UUID.randomUUID().toString()}"
|
||||
|
||||
podTemplate(label: label, inheritFrom: 'base', , containers: [
|
||||
containerTemplate(name: 'base', image: 'taylorchristieyardstick/build-base:node')
|
||||
]) {
|
||||
node(label) {
|
||||
stage('Checkout Project') {
|
||||
container('base') {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
stage('Install Dependencies') {
|
||||
container('base') {
|
||||
sh "npm ci"
|
||||
sh "npm install -g typescript"
|
||||
}
|
||||
}
|
||||
stage('Run unit tests') {
|
||||
container('base') {
|
||||
sh "npm test"
|
||||
}
|
||||
}
|
||||
stage('Build the Project') {
|
||||
container('base') {
|
||||
sh "tsc"
|
||||
}
|
||||
}
|
||||
stage('Login to Dockerhub') {
|
||||
withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
|
||||
container('base') {
|
||||
sh "docker login --username ${USER} --password ${PASS}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build the Docker Image') {
|
||||
container('base') {
|
||||
sh "make build"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push the Docker Image') {
|
||||
container('base') {
|
||||
sh "make push"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
.PHONY: help
|
||||
# from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
|
||||
help:
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n\n", $$1, $$2}'
|
||||
|
||||
repo=yardstick
|
||||
project=braid
|
||||
tag=$(shell git rev-parse --short=7 HEAD)
|
||||
branch=$(shell git rev-parse --abbrev-ref HEAD)
|
||||
version=$(shell git describe --exact-match --tags $(git log -n1 --pretty='%h'))
|
||||
|
||||
|
||||
full: build push ## build the docker container completely
|
||||
|
||||
|
||||
build: ## build the production dockerfile
|
||||
docker build -t $(repo)/$(project):$(tag) \
|
||||
-t $(repo)/$(project):$(branch) \
|
||||
.
|
||||
if git describe --exact-match --tags $(shell git log -n1 --pretty='%h'); then \
|
||||
docker tag $(repo)/$(project):$(tag) $(repo)/$(project):$(version); \
|
||||
fi
|
||||
push: ## push the production dockerfile
|
||||
docker push $(repo)/$(project):$(tag)
|
||||
docker push $(repo)/$(project):$(branch)
|
||||
if git describe --exact-match --tags $(shell git log -n1 --pretty='%h'); then \
|
||||
docker push $(repo)/$(project):$(version); \
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user