summaryrefslogtreecommitdiff
path: root/Jenkinsfile
blob: 05503b9ac185563e99243ec7d6cef199d95c1020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
pipeline {
    agent any

    parameters {
        booleanParam(name: 'DEPLOY', defaultValue: false, description: 'Publish bundles to release portal (/srv/releases, served on :8081)')
    }

    tools {
        gradle 'gradle-8.14'
    }

    options {
        timestamps()
        buildDiscarder(logRotator(numToKeepStr: '10'))
    }

    stages {
        stage('Assemble') {
            steps {
                sh 'gradle :modules:orgflow-domain:assemble'
            }
        }
        stage('jvm (x86_64)') {
            steps {
                sh 'gradle jvmTest :modules:orgflow-ui:jvmTest :modules:fsmp-transport:jvmTest :modules:orgflow-content-store:jvmTest'
            }
        }
        stage('android') {
            steps {
                sh 'gradle :modules:orgflow-domain:testDebugUnitTest :modules:orgflow-domain:testReleaseUnitTest'
            }
        }
        stage('wasm') {
            steps {
                sh 'gradle :modules:orgflow-domain:wasmJsNodeTest :modules:orgflow-content-store:wasmJsNodeTest'
            }
        }
        stage('linux native (x86_64)') {
            steps {
                sh 'gradle :modules:orgflow-domain:linuxX64Test'
            }
        }
        stage('Archive') {
            steps {
                archiveArtifacts artifacts: 'modules/orgflow-domain/build/libs/*.jar,modules/orgflow-domain/build/outputs/aar/*.aar,modules/orgflow-domain/build/js/packages/kukuri-wasm-js/kotlin/*,modules/orgflow-domain/build/bin/linuxX64/*/kukuri.kexe', fingerprint: true
            }
        }
        stage('Deploy') {
            when { expression { return params.DEPLOY } }
            steps {
                sh 'gradle :modules:orgflow-domain:bundleDesktop :modules:orgflow-domain:bundleWasmNode :modules:orgflow-domain:bundleWeb :modules:orgflow-domain:bundleNative'
                sh '''set -e
                PW=$(cat /run/secrets/git_pass)
                BASE="ftp://192.168.3.110/var/www/html/artifact/kukuri/latest"
                D="latest"
                # disk-constrained server: only 'latest' is kept (overwrites previous)
                for f in modules/orgflow-domain/build/distributions/*.zip; do
                  curl -sf -u ketsuban:$PW --ftp-create-dirs -T "$f" "$BASE/$D/$(basename "$f")"
                done
                # browser-runnable wasm app -> latest/web/
                rm -rf webout && mkdir -p webout
                unzip -q build/distributions/kukuri-wasm-web-*.zip -d webout
                # the FTP server disallows MKD: flatten nested composeResources
                # (res__<kind>__<file>) and remap in-app via FlatResourceReader
                find webout/composeResources -type f 2>/dev/null | while read -r f; do
                  rel=${f#webout/}
                  flat=$(printf '%s' "$rel" | sed -e 's|composeResources/||' -e 's|/|__|g')
                  cp "$f" "webout/$flat"
                done
                cd webout
                find . -type f | while read -r rel; do
                  curl -sf -u ketsuban:$PW --ftp-create-dirs -T "$rel" "$BASE/web/${rel#./}"
                done
                '''
            }
        }
    }

    post {
        always {
            junit allowEmptyResults: true, testResults: '**/build/test-results/**/*.xml'
        }
    }
}