fileserver/Jenkinsfile

101 lines
4.6 KiB
Plaintext
Raw Permalink Normal View History

2023-02-13 00:18:52 +00:00
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') {
2023-02-13 00:36:31 +00:00
sh 'apk add pkgconf musl-dev'
2023-02-13 00:18:52 +00:00
sh 'cargo build --release'
dir('target/release') {
stash includes: 'backend_rust', name: 'backend-muslc'
}
}
}
}
stage('Build frontend') {
agent { docker { image 'node:current-alpine' }}
2023-02-13 00:36:31 +00:00
options {
ansiColor('xterm')
}
2023-02-13 00:18:52 +00:00
steps {
dir('frontend') {
sh 'yarn install --frozen-lockfile'
sh 'yarn lint'
sh 'yarn build'
dir('dist') {
stash name: 'frontend'
}
}
}
}
}
}
stage('Package') {
2023-02-13 00:30:22 +00:00
agent { docker {
image 'alpine:latest'
reuseNode true
}}
2023-02-13 00:18:52 +00:00
steps {
sh 'apk add tar xz'
dir('static') {
unstash name: 'frontend'
}
unstash name: 'backend-glibc'
2023-02-13 00:41:57 +00:00
sh 'tar -cvJf linux-x64-glibc.tar.xz --transform="flags=r;s|backend_rust|server|" backend_rust static'
2023-02-13 00:18:52 +00:00
unstash name: 'backend-muslc'
2023-02-13 00:41:57 +00:00
sh 'tar -cvJf linux-x64-muslc.tar.xz --transform="flags=r;s|backend_rust|server|" backend_rust static'
2023-02-13 00:18:52 +00:00
archiveArtifacts artifacts: '*.tar.xz', allowEmptyArchive: false, onlyIfSuccessful: true
}
}
stage('Release') {
2023-02-13 00:30:22 +00:00
agent any
2023-02-13 00:18:52 +00:00
when { buildingTag() }
environment {
TOKEN = credentials('abd7020c-43d6-485b-ae09-2f9b484d9c15')
}
steps {
2023-02-13 00:30:22 +00:00
script {
def release_body = [
'name': "Version ${TAG_NAME}",
'tag_name': "${TAG_NAME}",
'is_draft': false,
'is_prerelease': false
]
2023-02-13 00:56:02 +00:00
def release_body_str = writeJSON returnText: true, json: release_body
2023-02-13 01:07:19 +00:00
def release_resp = httpRequest url: 'https://gitea.mattv.de/api/v1/repos/root/fileserver/releases',
2023-02-13 00:30:22 +00:00
acceptType: 'APPLICATION_JSON',
contentType: 'APPLICATION_JSON',
2023-02-13 05:34:50 +00:00
customHeaders: [[name: 'Authorization', value: "token ${TOKEN_PSW}", maskValue: true]],
2023-02-13 00:30:22 +00:00
httpMode: 'POST',
requestBody: release_body_str
2023-02-13 05:39:12 +00:00
def release_json = readJSON text: release_resp.content
2023-02-13 05:34:50 +00:00
httpRequest url: "https://gitea.mattv.de/api/v1/repos/root/fileserver/releases/${release_json.id}/assets?name=linux-x64-glibc.tar.xz",
2023-02-13 00:30:22 +00:00
httpMode: 'POST',
acceptType: 'APPLICATION_JSON',
2023-02-13 05:34:50 +00:00
customHeaders: [[name: 'Authorization', value: "token ${TOKEN_PSW}", maskValue: true]],
2023-02-13 00:30:22 +00:00
formData: [[contentType: 'application/octet-stream', name: 'attachment', fileName: 'linux-x64-glibc.tar.xz', uploadFile: 'linux-x64-glibc.tar.xz']]
2023-02-13 05:34:50 +00:00
httpRequest url: "https://gitea.mattv.de/api/v1/repos/root/fileserver/releases/${release_json.id}/assets?name=linux-x64-muslc.tar.xz",
2023-02-13 00:30:22 +00:00
httpMode: 'POST',
acceptType: 'APPLICATION_JSON',
2023-02-13 05:34:50 +00:00
customHeaders: [[name: 'Authorization', value: "token ${TOKEN_PSW}", maskValue: true]],
2023-02-13 00:30:22 +00:00
formData: [[contentType: 'application/octet-stream', name: 'attachment', fileName: 'linux-x64-muslc.tar.xz', uploadFile: 'linux-x64-muslc.tar.xz']]
}
2023-02-13 00:18:52 +00:00
}
}
}
}