Browse Source

add jenkins pipeline

tags/0.0.3.1
Vladimir Smagin 5 months ago
parent
commit
84ea8e2731
3 changed files with 70 additions and 0 deletions
  1. +18
    -0
      Dockerfile
  2. +51
    -0
      Jenkinsfile
  3. +1
    -0
      pkg/controller/mqtt/mqtt_controller.go

+ 18
- 0
Dockerfile View File

@@ -0,0 +1,18 @@
FROM golang:1.13-alpine

RUN apk update
RUN apk add git mercurial

WORKDIR /app/mqtt-operator
COPY . .

WORKDIR /app/mqtt-operator/cmd/manager

RUN CGO_ENABLED=0 go build
RUN go install

FROM alpine:3.11

COPY --from=0 /go/bin/manager /usr/local/bin/mqtt-operator

ENTRYPOINT ["/usr/local/bin/entrypoint"]

+ 51
- 0
Jenkinsfile View File

@@ -0,0 +1,51 @@
node {
checkout scm

def registry = "hub.docker.com"
def branch = env.BRANCH_NAME
def build = env.BUILD_NUMBER
def tag = "${branch}-${build}"
def image
def repository = "iam21h/mqtt-operator"
def image_name = "${repository}:${tag}"
def commit_hash = checkout(scm).GIT_COMMIT
def version

stage("Prepare version control") {
try {
version = readFile file: "VERSION"
echo "Detected version: ${version}"
} catch (Exception e) {
error("Failed to read version from file")
}
}

stage("Build Image") {
try {
sh "docker build -t ${image_name} ."
image = docker.image(image_name)
} catch (Exception e) {
error("Failed to build image")
}
}

// stage("Push Image") {
// try {

// docker.withRegistry("https://${registry}", "dockerhub") {
// image.push()
// }

// if (branch == "master") {
// docker.withRegistry("https://${registry}", "dockerhub") {
// image.push("latest")
// }
// }

// } catch(Exception e) {
// error("Failed to push image")
// } finally {
// sh "docker rmi ${image_name} || true"
// }
// }
}

+ 1
- 0
pkg/controller/mqtt/mqtt_controller.go View File

@@ -84,6 +84,7 @@ type ReconcileMQTT struct {
scheme *runtime.Scheme
}

// Reconcile resources
func (r *ReconcileMQTT) Reconcile(request reconcile.Request) (reconcile.Result, error) {
reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
reqLogger.Info("Reconciling MQTT")


Loading…
Cancel
Save