Mutzi
d5101c5651
Some checks failed
Gitea Organization/fileserver/pipeline/head There was a failure building this commit
101 lines
4.6 KiB
Groovy
101 lines
4.6 KiB
Groovy
pipeline {
|
|
agent none
|
|
stages {
|
|
stage('Build') {
|
|
parallel {
|
|
stage('Build backend-glibc') {
|
|
agent { docker { image 'rust:bullseye' }}
|
|
steps {
|
|
dir('backend') {
|
|
sh 'cargo build --release'
|
|
dir('target/release') {
|
|
stash includes: 'backend_rust', name: 'backend-glibc'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Build backend-muslc') {
|
|
agent { docker { image 'rust:alpine' }}
|
|
steps {
|
|
dir('backend') {
|
|
sh 'apk add pkgconf musl-dev'
|
|
sh 'cargo build --release'
|
|
dir('target/release') {
|
|
stash includes: 'backend_rust', name: 'backend-muslc'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Build frontend') {
|
|
agent { docker { image 'node:current-alpine' }}
|
|
options {
|
|
ansiColor('xterm')
|
|
}
|
|
steps {
|
|
dir('frontend') {
|
|
sh 'yarn install --frozen-lockfile'
|
|
sh 'yarn lint'
|
|
sh 'yarn build'
|
|
dir('dist') {
|
|
stash name: 'frontend'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Package') {
|
|
agent { docker {
|
|
image 'alpine:latest'
|
|
reuseNode true
|
|
}}
|
|
steps {
|
|
sh 'apk add tar xz'
|
|
dir('static') {
|
|
unstash name: 'frontend'
|
|
}
|
|
unstash name: 'backend-glibc'
|
|
sh 'tar -cvJf --transform="flags=r;s|backend_rust|server|" linux-x64-glibc.tar.xz backend_rust static'
|
|
unstash name: 'backend-muslc'
|
|
sh 'tar -cvJf --transform="flags=r;s|backend_rust|server|" linux-x64-muslc.tar.xz backend_rust static'
|
|
archiveArtifacts artifacts: '*.tar.xz', allowEmptyArchive: false, onlyIfSuccessful: true
|
|
}
|
|
}
|
|
stage('Release') {
|
|
agent any
|
|
when { buildingTag() }
|
|
environment {
|
|
TOKEN = credentials('abd7020c-43d6-485b-ae09-2f9b484d9c15')
|
|
}
|
|
steps {
|
|
script {
|
|
def release_body = [
|
|
'name': "Version ${TAG_NAME}",
|
|
'tag_name': "${TAG_NAME}",
|
|
'is_draft': false,
|
|
'is_prerelease': false
|
|
]
|
|
def release_body_str = writeJSON returnText: true, data: release_body
|
|
def release_resp = httpRequest 'https://gitea.mattv.de/api/v1/repos/root/fileserver/releases',
|
|
acceptType: 'APPLICATION_JSON',
|
|
contentType: 'APPLICATION_JSON',
|
|
customHeaders: [[name: 'Authorization', value: 'token ${TOKEN_PSW}', maskValue: true]],
|
|
httpMode: 'POST',
|
|
requestBody: release_body_str
|
|
def release_json = readJson text: release_resp.content
|
|
httpRequest 'https://gitea.mattv.de/api/v1/repos/root/fileserver/releases/${release_json.id}/assets?name=linux-x64-glibc.tar.xz',
|
|
httpMode: 'POST',
|
|
acceptType: 'APPLICATION_JSON',
|
|
customHeaders: [[name: 'Authorization', value: 'token ${TOKEN_PSW}', maskValue: true]],
|
|
formData: [[contentType: 'application/octet-stream', name: 'attachment', fileName: 'linux-x64-glibc.tar.xz', uploadFile: 'linux-x64-glibc.tar.xz']]
|
|
httpRequest 'https://gitea.mattv.de/api/v1/repos/root/fileserver/releases/${release_json.id}/assets?name=linux-x64-muslc.tar.xz',
|
|
httpMode: 'POST',
|
|
acceptType: 'APPLICATION_JSON',
|
|
customHeaders: [[name: 'Authorization', value: 'token ${TOKEN_PSW}', maskValue: true]],
|
|
formData: [[contentType: 'application/octet-stream', name: 'attachment', fileName: 'linux-x64-muslc.tar.xz', uploadFile: 'linux-x64-muslc.tar.xz']]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|