Adde Makefile and remove Jenkinsfile

This commit is contained in:
Marcus Noble 2020-05-08 10:57:47 +01:00
parent 3d9db38425
commit 71bbf39d55
2 changed files with 61 additions and 61 deletions

61
Jenkinsfile vendored
View File

@ -1,61 +0,0 @@
pipeline {
agent { label "dind" }
stages {
stage('Create Docker image') {
steps {
container('docker') {
sh """
docker build -t docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} .
"""
}
}
}
stage('Publish Docker image') {
when { branch 'master' }
environment {
DOCKER_CREDS = credentials('Harbor')
}
steps {
container('docker') {
sh """
docker login docker.cloud.cluster.fun -u $DOCKER_CREDS_USR -p $DOCKER_CREDS_PSW
docker tag docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} docker.cloud.cluster.fun/averagemarcus/blog:latest
docker push docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT}
docker push docker.cloud.cluster.fun/averagemarcus/blog:latest
"""
}
}
}
stage('Restart deployment') {
when { branch 'master' }
steps {
container('kubectl') {
sh """
set +x
mkdir -p ~/.kube/
printf "\$CLOUD_KUBECONFIG" > ~/.kube/config
kubectl --kubeconfig ~/.kube/config rollout restart deployment/blog --namespace default
"""
}
}
}
stage('Mirror to GitHub') {
when { branch 'master' }
environment {
GITHUB_TOKEN = credentials('Github_token')
}
steps {
sh """
git remote add github https://${GITHUB_TOKEN}:@github.com/AverageMarcus/blog.git
git push github HEAD:master
"""
}
}
}
}

61
Makefile Normal file
View File

@ -0,0 +1,61 @@
.DEFAULT_GOAL := default
IMAGE ?= docker.cloud.cluster.fun/averagemarcus/blog:latest
.PHONY: test # Run all tests, linting and format checks
test: lint check-format run-tests
.PHONY: lint # Perform lint checks against code
lint:
@echo "⚠️ 'lint' unimplemented"
.PHONY: check-format # Checks code formatting and returns a non-zero exit code if formatting errors found
check-format:
@echo "⚠️ 'check-format' unimplemented"
.PHONY: format # Performs automatic format fixes on all code
format:
@echo "⚠️ 'format' unimplemented"
.PHONY: run-tests # Runs all tests
run-tests:
@echo "⚠️ 'run-tests' unimplemented"
.PHONY: fetch-deps # Fetch all project dependencies
fetch-deps:
@npm install
.PHONY: build # Build the project
build: lint check-format fetch-deps
@echo "⚠️ 'build' unimplemented"
.PHONY: docker-build # Build the docker image
docker-build:
@docker build -t $(IMAGE) .
.PHONY: docker-publish # Push the docker image to the remote registry
docker-publish:
@docker push $(IMAGE)
.PHONY: run # Run the application
run:
@npm start
.PHONY: ci # Perform CI specific tasks to perform on a pull request
ci:
@echo "⚠️ 'ci' unimplemented"
.PHONY: release # Release the latest version of the application
release:
@echo "⚠️ 'release' unimplemented"
.PHONY: help # Show this list of commands
help:
@echo "${REPO_NAME}"
@echo "Usage: make [target]"
@echo ""
@echo "target description" | expand -t20
@echo "-----------------------------------"
@grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20
default: test build