From 6b88052cd7a713bd1252af3ef859bbeb4e318975 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 26 Nov 2020 03:59:36 +0100 Subject: [PATCH] add Jenkinsfile and some Makefile targets for CI (#302) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub Sokołowski Co-authored-by: Oskar Thorén --- Jenkinsfile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..146a04aa9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,61 @@ +pipeline { + agent { label 'linux' } + + parameters { + string( + name: 'BRANCH', + defaultValue: 'master', + description: 'Name of branch to build.' + ) + string( + name: 'IMAGE_TAG', + defaultValue: 'wakunode2', + description: 'Name of Docker tag to push.' + ) + string( + name: 'IMAGE_NAME', + defaultValue: 'statusteam/nim-waku', + description: 'Name of Docker image to push.' + ) + string( + name: 'NIM_PARAMS', + defaultValue: '-d:disableMarchNative -d:chronicles_colors:none -d:insecure', + description: 'Flags for Nim compilation.' + ) + } + + options { + timestamps() + /* manage how many builds we keep */ + buildDiscarder(logRotator( + numToKeepStr: '10', + daysToKeepStr: '30', + )) + } + + stages { + stage('Build') { + steps { script { + image = docker.build( + "${params.IMAGE_NAME}:${env.GIT_COMMIT.take(6)}", + "--build-arg=MAKE_TARGET='${params.IMAGE_TAG}' " + + "--build-arg=NIM_PARAMS='${params.NIM_PARAMS}' ." + ) + } } + } + + stage('Push') { + steps { script { + withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) { + image.push() + } + withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) { + image.push(params.IMAGE_TAG) + } + } } + } + } // stages + post { + always { sh 'docker image prune -f' } + } // post +} // pipeline