From 4ca6497a28ba02a0edc8070ddd49e5b51db81e89 Mon Sep 17 00:00:00 2001 From: The_Spider <nhyatt@smoothnet.org> Date: Mon, 7 Feb 2022 15:30:57 -0600 Subject: [PATCH] Adds Jenkinsfile --- Jenkinsfile | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..ce315e2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,70 @@ +#!groovy + +def repository = "registry.c.test-chamber-13.lan" +def repositoryCreds = "harbor-repository-creds" + +def label = "kubernetes-${UUID.randomUUID().toString()}" +def templateName = "pipeline-worker" +podTemplate( + label: label, + name: templateName, + yaml: functions.podYaml( + repo: repository, + templateName: templateName, + [ + [ + name: "compile", + path: "${repository}/dockerhub/library/golang:alpine", + ] + ] + ) +) { + node (label) { + def workspace = pwd() + + stage ("Pull Local Repo") { + checkout([ + $class: "GitSCM", + branches: [ + [ + name: "refs/remotes/origin/main", + ], + ], + userRemoteConfigs: [ + [ + url: "ssh://git@gitea.smoothnet.org:31822/nhyatt/bind-response-policy-zone-creator.git", + credentialsId: "Gitea-Read-Only-Token", + ], + ], + extensions: [ + [ + $class: "CloneOption", + shallow: true, + ], + [ + $class: "CheckoutOption", + timeout: 2, + ], + ], + ]) + } + + stage("Build Binary") { + container("compile") { + sh """ + apk add --no-cache gcc musl-dev upx + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -ldflags="-s -w" -tags timetzdata -o pihole-zone-generator ./cmd/bind + upx --lzma pihole-zone-generator + """ + } + } + + stage ("Store Artifacts") { + archiveArtifacts (artifacts: "pihole-zone-generator", + fingerprint: true, + allowEmptyArchive: false, + onlyIfSuccessful: true, + ) + } + } +} \ No newline at end of file