From 140f0f7593ee5417d97d30278cfb7c00544fba30 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Fri, 15 Nov 2024 23:22:07 +0100 Subject: [PATCH] Jenkinsfile v1. Build, unit test build image using kaniko, integraiton test. THe nexus docker proxy is used as well as the nexus go proxy. Also for the normal build, a cache RWX PVC is used. --- Jenkinsfile | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..12ce8ec --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,80 @@ + +pipeline { + agent { + kubernetes agentsetup(containers: 'go-1-23-2,docker,kaniko' ) + } + options { + disableConcurrentBuilds() + buildDiscarder(logRotator( + numToKeepStr: '5', // Number of build records to keep + artifactNumToKeepStr: '3', // Number of builds for which to keep artifacts + daysToKeepStr: '30', // Days to keep builds + artifactDaysToKeepStr: '15' // Days to keep artifacts + )) + } + environment { + REGISTRY = "lodge.wamblee.org" + IMAGE_NAME = "converge" + IMAGE_TAG = "${BUILD_NUMBER}" + } + stages { + stage('Checkout') { + steps { + git credentialsId: 'aa7540b3-6e80-4d5e-97d4-852da70986b9', + url: 'https://git.wamblee.org/erik/converge.git', + branch: 'main' + } + } + stage('Build') { + steps { + sh """ + export + cd /home/jenkins/agent/workspace/gobuildertest + make build + """ + } + } + stage('Unit test') { + steps { + sh """ + make test + """ + } + } + stage('Build images') { + steps { + container('kaniko') { + sh ''' + /kaniko/executor \ + --build-arg GOPROXY="$GOPROXY" \ + --build-arg GOSUMDB="$GTOSUMDB" \ + --registry-mirror wharf.wamblee.org \ + --context=dir://. \ + --dockerfile=Dockerfile.prod \ + --destination=${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} \ + --destination=${REGISTRY}/${IMAGE_NAME}:latest + rm -rf /kaniko/*[0-9]* && rm -rf /kaniko/Dockerfile && mkdir -p /workspace + ''' + sh ''' + /kaniko/executor \ + --build-arg GOPROXY="$GOPROXY" \ + --build-arg GOSUMDB="$GTOSUMDB" \ + --registry-mirror wharf.wamblee.org \ + --context=dir://. \ + --dockerfile=Dockerfile.test \ + --destination=${REGISTRY}/${IMAGE_NAME}-test:${IMAGE_TAG} \ + --destination=${REGISTRY}/${IMAGE_NAME}-test:latest + ''' + } + } + } + stage('Integration test') { + steps { + sh """ + make integrationtest + """ + } + } + } + +}