From 36e6ecb824ede447d3cf4ca6b111c87d373e39c1 Mon Sep 17 00:00:00 2001 From: Josh Burman Date: Wed, 11 Aug 2021 11:29:05 -0400 Subject: [PATCH 1/2] added makefile --- Makefile | 31 +++++++++++++++++++++++++++++++ docker_tag.txt | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e69de29..f174c88 100644 --- a/Makefile +++ b/Makefile @@ -0,0 +1,31 @@ +.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=measure-solver +branch=$(shell git rev-parse --abbrev-ref HEAD) +tag=$(shell echo $(branch) | grep -Eo 'feature/([A-Za-z]+-[0-9]*)' | grep -Eo '[A-Za-z]+-[0-9]*' || \ + echo $(branch) | grep -Eo '(release|hotfix)/[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' || \ + echo $(branch) | grep -Eo 'QUANT-([[:digit:]]*)') +full: build push + + +build: ## build the production dockerfile + @if [[ -n "$(tag)" ]]; then \ + echo "$(tag)" > docker_tag.txt; \ + docker build -t $(repo)/$(project):$(tag) .; \ + else \ + echo "Nothing to build."; \ + fi +push: ## push the production dockerfile + @if [[ -n "$(tag)" ]]; then \ + docker push $(repo)/$(project):$(tag); \ + else \ + echo "Nothing to push."; \ + fi + +display: ## display the tag/branch values for development testing + @echo "branch: $(branch)" + @echo "tag: $(tag)" diff --git a/docker_tag.txt b/docker_tag.txt index 49d5957..8a6ce5f 100644 --- a/docker_tag.txt +++ b/docker_tag.txt @@ -1 +1 @@ -0.1 +QUANT-987 From 50cdc699f41bcd4bf27b95fb845af2c846084dd1 Mon Sep 17 00:00:00 2001 From: Taylor Christie Date: Wed, 11 Aug 2021 09:30:47 -0600 Subject: [PATCH 2/2] [QUANT-987] Added jenkinsfile for CI/CD --- Jenkinsfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5eef75c --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,25 @@ +def label = "docker-${UUID.randomUUID().toString()}" + +podTemplate(label: label, inheritFrom: 'base') { + node(label) { + stage('Checkout Repository') { + container('base') { + checkout scm + } + } + + stage('Login to Dockerhub') { + withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) { + container('base') { + sh "docker login --username ${USER} --password ${PASS}" + } + } + } + + stage('Build Docker image') { + container('base') { + sh "make display full branch=${BRANCH_NAME}" + } + } + } +} \ No newline at end of file