Skip to content

Commit

Permalink
Created jenkinsfile for liteprotocoltester deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
NagyZoltanPeter committed Oct 17, 2024
1 parent 33c6ed0 commit 460f561
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,11 @@ docker-push:
DOCKER_LPT_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure

# build a docker image for the fleet
docker-liteprotocoltester: DOCKER_LPT_TAG ?= liteprotocoltester-$(GIT_VERSION)
docker-liteprotocoltester: DOCKER_LPT_NAME ?= wakuorg/liteprotocoltester:latest
docker-liteprotocoltester: DOCKER_LPT_TAG ?= latest
docker-liteprotocoltester: DOCKER_LPT_NAME ?= wakuorg/liteprotocoltester:$(DOCKER_LPT_TAG)
docker-liteprotocoltester:
docker build \
--no-cache \
-D \
--build-arg="MAKE_TARGET=liteprotocoltester" \
--build-arg="NIMFLAGS=$(DOCKER_LPT_NIMFLAGS)" \
--build-arg="NIM_COMMIT=$(DOCKER_NIM_COMMIT)" \
Expand Down
101 changes: 101 additions & 0 deletions ci/Jenkinsfile.lpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env groovy
library '[email protected]'

pipeline {
agent { label 'linux' }

options {
timestamps()
timeout(time: 20, unit: 'MINUTES')
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
))
}

parameters {
string(
name: 'IMAGE_TAG',
description: 'Name of Docker tag to push. Optional Parameter.',
defaultValue: 'latest'
)
string(
name: 'IMAGE_NAME',
description: 'Name of Docker image to push.',
defaultValue: params.IMAGE_NAME ?: 'harbor.status.im/wakuorg/liteprotocoltester',
)
string(
name: 'DOCKER_CRED',
description: 'Name of Docker Registry credential.',
defaultValue: params.DOCKER_CRED ?: 'harbor-wakuorg-robot',
)
string(
name: 'DOCKER_REGISTRY_URL',
description: 'URL of the Docker Registry',
defaultValue: params.DOCKER_REGISTRY_URL ?: 'https://harbor.status.im'
)
string(
name: 'NIMFLAGS',
description: 'Flags for Nim compilation.',
defaultValue: params.NIMFLAGS ?: [
'--colors:off',
'-d:disableMarchNative',
'-d:chronicles_colors:none',
'-d:insecure',
].join(' ')
)
choice(
name: "LOWEST_LOG_LEVEL_ALLOWED",
choices: ['TRACE', 'DEGUG', 'INFO', 'NOTICE', 'WARN', 'ERROR', 'FATAL'],
description: "Defines the log level, which will be available at runtime (Chronicles log level)",
defaultValue: 'TRACE'
)
}

stages {
stage('Build') {
steps { script {
image = docker.build(
"${params.IMAGE_NAME}:${params.IMAGE_TAG ?: env.GIT_COMMIT.take(8)}",
"--label=commit='${git.commit()}' " +
"--label=version='${git.describe('--tags')}' " +
"--build-arg=MAKE_TARGET='liteprotocoltester' " +
"--build-arg=NIMFLAGS='${params.NIMFLAGS}' " +
"--build-arg=LOG_LEVEL='${params.LOWEST_LOG_LEVEL_ALLOWED}' " +
"--file=apps/liteprotocoltester/Dockerfile.liteprotocoltester.compile " +
" ."
)
} }
}

stage('Check') {
steps { script {
image.inside('--entrypoint=""') { c ->
sh '/usr/bin/liteprotocoltester --version'
}
} }
}

stage('Push') {
when { expression { params.IMAGE_TAG != '' } }
steps { script {
withDockerRegistry([
credentialsId: params.DOCKER_CRED, url: params.DOCKER_REGISTRY_URL
]) {
image.push(params.IMAGE_TAG)
}
} }
}
} // stages

post {
success { script {
discord.send(
header: '**Nim-Waku:liteprotocoltester deployment successful!**',
cred: 'discord-waku-deployments-webhook',
descPrefix: "Image: [`${IMAGE_NAME}:${IMAGE_TAG}`](https://hub.docker.com/r/${IMAGE_NAME}/tags?name=${IMAGE_TAG})"
)
} }
always { sh 'docker image prune -f' }
} // post
} // pipeline

0 comments on commit 460f561

Please sign in to comment.