rvr-nextgen/Jenkinsfile

118 lines
4.1 KiB
Plaintext
Raw Permalink Normal View History

2023-04-08 00:42:55 +02:00
pipeline {
agent {
node {
label 'rvr'
customWorkspace 'workspace/rvr'
}
}
stages {
stage('Install composer') {
environment {
COMPOSER_HOME="${WORKSPACE}/.composer"
}
agent {
dockerfile {
2023-09-28 12:03:23 +02:00
filename 'docker/Dockerfile'
2023-04-08 00:42:55 +02:00
dir '.'
2023-09-28 12:03:23 +02:00
additionalBuildArgs '--target rvr_base'
2023-04-08 00:42:55 +02:00
reuseNode true
}
}
steps {
sh 'composer install'
}
}
stage('Unit Testing') {
agent {
dockerfile {
2023-09-28 12:03:23 +02:00
filename 'docker/Dockerfile'
2023-04-08 00:42:55 +02:00
dir '.'
2023-09-28 12:03:23 +02:00
additionalBuildArgs '--target rvr_base'
2023-04-08 00:42:55 +02:00
reuseNode true
}
}
steps {
sh 'vendor/bin/phpunit --log-junit unit_test_results.xml --testdox tests'
}
post {
2023-05-28 16:39:38 +02:00
always {
2023-04-08 00:42:55 +02:00
archiveArtifacts 'unit_test_results.xml'
}
}
}
stage('Static Code Analysis') {
agent {
dockerfile {
2023-09-28 12:03:23 +02:00
filename 'docker/Dockerfile'
2023-04-08 00:42:55 +02:00
dir '.'
2023-09-28 12:03:23 +02:00
additionalBuildArgs '--target rvr_base'
2023-04-08 00:42:55 +02:00
reuseNode true
}
}
steps {
sh 'php vendor/bin/phpstan analyse -c phpstan.neon --error-format=prettyJson > static_code_analysis_results.json'
}
post {
2023-05-28 16:39:38 +02:00
always {
2023-04-08 00:42:55 +02:00
archiveArtifacts 'static_code_analysis_results.json'
}
}
}
2023-09-28 12:04:49 +02:00
stage('Prepare Docker release') {
environment {
COMPOSER_HOME="${WORKSPACE}/.composer"
npm_config_cache="${WORKSPACE}/.npm"
}
agent {
dockerfile {
filename 'docker/Dockerfile'
dir '.'
additionalBuildArgs '--target rvr_base'
reuseNode true
}
}
steps {
script {
sh script: 'git clean -ffdx', label: 'Clean repository'
env.VERSION = sh(script: 'git describe --tags --always --match "Release_*" HEAD', returnStdout: true).trim()
sh script: 'docker/scripts/release.sh', label: 'Release script'
sh script: "rm -rf ${env.COMPOSER_HOME} ${env.npm_config_cache}"
}
}
}
stage('Release Docker image') {
steps {
script {
withDockerRegistry([credentialsId: 'gitea-system-user', url: 'https://git.esoko.eu/']) {
sh script: 'docker buildx create --use --bootstrap --platform=linux/arm64,linux/amd64 --name multi-platform-builder'
sh script: """docker buildx build \
--platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
--target rvr_release \
-t git.esoko.eu/esoko/rvr:${env.VERSION} \
--push \
.""",
label: 'Build Docker image'
2023-10-01 00:04:08 +02:00
if (env.BRANCH_NAME == 'master') {
2023-10-01 00:13:27 +02:00
if (env.VERSION ==~ '.*-\\d+-g[a-f0-9]{7}') {
2023-10-01 00:04:08 +02:00
env.FIXED_VERSION = 'dev'
} else {
env.FIXED_VERSION = 'stable'
}
sh script: """docker buildx imagetools create \
-t git.esoko.eu/esoko/rvr:${env.FIXED_VERSION} \
git.esoko.eu/esoko/rvr:${env.VERSION}"""
}
2023-09-28 12:04:49 +02:00
}
}
}
}
2023-04-08 00:42:55 +02:00
}
}