Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Private Jenkins job for releasing
Browse files Browse the repository at this point in the history
Change-Id: I496ec38bc5896d6be34c6c784ec1a2a322ad07f9
  • Loading branch information
kaloyan-raev committed Aug 18, 2020
1 parent f92725e commit ccded0a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.coverprofile
.k8s
velero-plugin-storj
velero-plugin-for-tardigrade
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.14-buster AS build
ENV GOPROXY=https://proxy.golang.org
WORKDIR /storj
COPY . .
RUN make go-build
COPY . /go/src/velero-plugin-for-tardigrade
WORKDIR /go/src/velero-plugin-for-tardigrade
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /go/bin/velero-plugin-for-tardigrade ./cmd

FROM ubuntu:bionic
RUN mkdir /plugins
COPY --from=build /storj/velero-plugin-storj /plugins/
COPY --from=build /go/bin/velero-plugin-for-tardigrade /plugins/
USER nobody:nogroup
ENTRYPOINT ["/bin/bash", "-c", "cp /plugins/* /target/."]
36 changes: 36 additions & 0 deletions Jenkinsfile.private
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
node('node') {
properties([disableConcurrentBuilds()])
try {
currentBuild.result = "SUCCESS"

stage('Checkout') {
checkout scm

echo "Current build result: ${currentBuild.result}"
}

stage('Build Images') {
sh 'make plugin-build'

echo "Current build result: ${currentBuild.result}"
}

stage('Push Images') {
sh 'make push'

echo "Current build result: ${currentBuild.result}"
}
}
catch (err) {
echo "Caught errors! ${err}"
echo "Setting build result to FAILURE"
currentBuild.result = "FAILURE"
throw err
}
finally {
stage('Cleanup') {
sh 'make clean'
deleteDir()
}
}
}
36 changes: 25 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
K8S_DIR := .k8s
K8S_CLUSTER_NAME := storj
K8S_CLUSTER_NAME := tardigrade
KUBECONFIG = $(realpath $(K8S_DIR)/config)
BUCKET_NAME ?= velero
STORJ_ACCESS ?= # Required
DOCKER_IMAGE := storjthirdparty/velero-plugin
DOCKER_TAG ?= dev
VELERO_BACKUP_LOCATION := default

export KUBECONFIG

DOCKER_IMAGE := storjlabs/velero-plugin
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD | sed "s!/!-!g")
DOCKER_TAG := ${BRANCH_NAME}
ifneq (,$(shell git describe --tags --exact-match --match "v[0-9]*\.[0-9]*\.[0-9]*" --exclude "v[0-9]*\.[0-9]*\.[0-9]*[!0-9]*"))
DOCKER_TAG_LATEST := true
endif

define HELP_MSG
Run a reproducible local development environment to develop the Storj Velero \
plugin. Usage: make [target]
Run a reproducible local development environment to develop the Velero \
plugin for Tardigrade. Usage: make [target]
endef

.PHONY: help
Expand Down Expand Up @@ -42,14 +47,14 @@ velero-plugin-remove: ## delete this plugin from Velero server
@velero plugin remove $(DOCKER_IMAGE):$(DOCKER_TAG)

.PHONY: velero-backup-location-create
velero-backup-location-create: .is-access-set ## create a backup location using Storj plugin
velero-backup-location-create: .is-access-set ## create a backup location using Tardigrade plugin
@velero backup-location create $(VELERO_BACKUP_LOCATION) \
--bucket=$(BUCKET_NAME) \
--config accessGrant=$(STORJ_ACCESS) \
--provider=tardigrade

.PHONY: velero-backup-location-delete
velero-backup-location-delete: ## delete the backup location that uses Storj plugin
velero-backup-location-delete: ## delete the backup location that uses Tardigrade plugin
@kubectl -n velero delete backupstoragelocation.velero.io $(VELERO_BACKUP_LOCATION)

.PHONY: velero-uninstall
Expand All @@ -69,13 +74,22 @@ plugin-image-push: ## push the plugin image to the local K8s cluster

.PHONY: go-build
go-build: ## build the Go source
@CGO_ENABLED=0 go build -o velero-plugin-storj ./cmd
@CGO_ENABLED=0 go build -o velero-plugin-for-tardigrade ./cmd

.PHONY: test
test: ## Run tests on source code
cd testsuite; go test -race -v -cover -coverprofile=.coverprofile ./...
@echo done


.PHONY: push
push: plugin-build ## pushes the Docker image to Docker Hub
@docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
ifeq ($(DOCKER_TAG_LATEST), true)
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest
docker push $(DOCKER_IMAGE):latest
endif

.PHONY: dev-env-init
dev-env-init: k8s-start velero-install ## start K8s cluster and install Velero

Expand All @@ -87,12 +101,12 @@ dev-env-refresh: velero-plugin-remove dev-env-start ## build the plugin again an

.PHONY: dev-env-destroy
dev-env-destroy: ## destroy the local development environment
@kind delete cluster --name $(K8S_CLUSTER_NAME) || true
@rm -rf $(K8S_DIR)
-@kind delete cluster --name $(K8S_CLUSTER_NAME)
-@rm -rf $(K8S_DIR)

.PHONY: clean
clean: dev-env-destroy ## clean up the local environment on your local machine
@docker image rm -f $(DOCKER_IMAGE):$(DOCKER_TAG) || true
-@docker image rm -f $(DOCKER_IMAGE):$(DOCKER_TAG)

.PHONY: .is-access-set
.is-access-set:
Expand Down

0 comments on commit ccded0a

Please sign in to comment.