-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created jenkinsfile for liteprotocoltester deployment
- Loading branch information
1 parent
33c6ed0
commit 460f561
Showing
2 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |