antos-appimage/Jenkinsfile

161 lines
5.9 KiB
Plaintext
Raw Normal View History

2022-09-29 22:08:26 +02:00
// need to approve all static functions in Dashboard > Manage Jenkins > ScriptApproval
2022-09-29 23:57:06 +02:00
// method hudson.model.Item getAllJobs
// method hudson.model.Item getName
// method hudson.model.ItemGroup getItem java.lang.String
// method hudson.model.ItemGroup getItems
// method jenkins.model.Jenkins getItemByFullName java.lang.String
// new java.util.ArrayList
2022-09-29 23:58:39 +02:00
// staticMethod jenkins.model.Jenkins getInstance
2022-09-29 23:20:38 +02:00
def ArrayList<String> getBranches(projectName){
def jobs = jenkins.model.Jenkins.instance.getItemByFullName(projectName).getAllJobs();
2022-09-29 23:18:11 +02:00
Iterator<?> iterator = jobs.iterator();
def arr = new ArrayList<String>();
while (iterator.hasNext()) {
def job = iterator.next();
arr.add(job.getName());
}
return arr;
2022-09-29 23:13:25 +02:00
}
2022-09-29 23:18:11 +02:00
2022-09-29 23:13:25 +02:00
def generateStage(name) {
return {
2022-09-29 23:25:49 +02:00
stage("ANTOS ${name}") {
copyArtifacts(projectName: 'gitea-sync/antos/' + name, target: 'antos/frontend/' + name);
2023-06-01 16:48:19 +02:00
copyArtifacts(projectName: 'gitea-sync/antosdk-apps/' + name, target: 'antos/packages/' + name, optional: true);
2023-06-01 16:46:31 +02:00
2022-09-29 23:30:38 +02:00
env.tag = name;
sh'''
2022-09-29 23:34:56 +02:00
echo "Deploy antos webapps for version $tag"
set -e
set -x
2022-09-29 23:38:37 +02:00
cp -rfv antos/webapps/build/opt/www/htdocs/os antos/frontend/$tag/build/opt/www/htdocs
2023-01-27 16:22:52 +01:00
# mv antos/frontend/$tag/build/opt/www/htdocs/os/mimes.json antos/frontend/$tag/build/opt/www/htdocs/
2023-01-03 17:58:52 +01:00
# release antos doc
2023-01-03 18:40:19 +01:00
[ -d "/home/dany/public/antos-release/doc/$tag" ] && rm -rf /home/dany/public/antos-release/doc/$tag || true
2023-01-03 18:11:10 +01:00
[ -d "antos/frontend/$tag/doc" ] && cp -rf antos/frontend/$tag/doc /home/dany/public/antos-release/doc/$tag || true
2023-05-30 09:20:40 +02:00
# release antos sdk
[ -d "/home/dany/public/antos-release/sdk/$tag" ] && rm -rf /home/dany/public/antos-release/sdk/$tag || true
[ -d "antos/frontend/$tag/d.ts" ] && cp -rf antos/frontend/$tag/d.ts /home/dany/public/antos-release/sdk/$tag || true
2023-05-30 13:37:41 +02:00
echo $tag >> /home/dany/public/antos-release/sdk/versions.txt
2023-06-01 16:46:31 +02:00
# release antos packages
if [ -d "antos/packages/$tag" ]; then
[ -d "/home/dany/public/antos-release/packages/$tag" ] && rm -rf /home/dany/public/antos-release/packages/$tag || true
cp -rf antos/packages/$tag/release /home/dany/public/antos-release/packages/$tag
fi
2022-09-29 23:30:38 +02:00
'''
2022-09-29 23:13:25 +02:00
}
}
}
2022-09-29 23:20:38 +02:00
def parallelStagesMap = getBranches("gitea-sync/antos").collectEntries {
2022-09-29 23:18:11 +02:00
["${it}" : generateStage(it)]
2022-09-29 22:40:38 +02:00
}
2022-09-29 23:13:25 +02:00
2022-09-20 11:44:57 +02:00
pipeline{
2022-09-29 21:30:24 +02:00
agent { node{ label'workstation' }}
2022-09-20 11:44:57 +02:00
options {
// Limit build history with buildDiscarder option:
// daysToKeepStr: history is only kept up to this many days.
// numToKeepStr: only this many build logs are kept.
// artifactDaysToKeepStr: artifacts are only kept up to this many days.
// artifactNumToKeepStr: only this many builds have their artifacts kept.
buildDiscarder(logRotator(numToKeepStr: "1"))
// Enable timestamps in build log console
timestamps()
// Maximum time to run the whole pipeline before canceling it
timeout(time: 3, unit: 'HOURS')
// Use Jenkins ANSI Color Plugin for log console
ansiColor('xterm')
// Limit build concurrency to 1 per branch
disableConcurrentBuilds()
}
stages
{
2022-09-29 21:30:24 +02:00
stage('Prepare binaries') {
2022-09-20 14:51:40 +02:00
steps {
2022-09-29 21:30:24 +02:00
sh'''
[ -d build ] && rm -rf build
2022-09-29 23:25:49 +02:00
mkdir build
[ -d antos ] && rm -rf antos
mkdir -p antos/frontend
mkdir -p antos/backend
2022-09-29 23:34:56 +02:00
mkdir -p antos/webapps
2023-06-01 16:46:31 +02:00
mkdir -p antos/packages
2023-05-30 13:38:46 +02:00
cat /dev/null > /home/dany/public/antos-release/sdk/versions.txt
2022-09-29 21:30:24 +02:00
'''
2022-09-29 23:25:49 +02:00
copyArtifacts(projectName: 'gitea-sync/ant-http/master', target: 'antos/backend');
2023-01-27 16:07:53 +01:00
copyArtifacts(projectName: 'gitea-sync/antd-fcgi-plugin/master', target: 'antos/backend');
2023-01-27 15:56:44 +01:00
copyArtifacts(projectName: 'gitea-sync/luafcgi/master', target: 'antos/backend');
2022-09-29 23:25:49 +02:00
copyArtifacts(projectName: 'gitea-sync/antd-tunnel-plugin/master', target: 'antos/backend');
copyArtifacts(projectName: 'gitea-sync/antd-wvnc-plugin/master', target: 'antos/backend');
copyArtifacts(projectName: 'gitea-sync/antd-tunnel-publishers/master', target: 'antos/backend');
copyArtifacts(projectName: 'luasocket', target: 'antos/backend');
copyArtifacts(projectName: 'luasec', target: 'antos/backend');
2023-01-27 16:02:18 +01:00
copyArtifacts(projectName: 'gitea-sync/silk/master', target: 'antos/backend');
2023-01-27 15:56:44 +01:00
copyArtifacts(projectName: 'gitea-sync/antos-backend/master', target: 'antos/webapps');
2022-09-29 22:29:50 +02:00
script
{
2022-09-29 23:18:11 +02:00
parallel parallelStagesMap;
2022-09-29 22:29:50 +02:00
}
2022-09-29 21:31:29 +02:00
sh'''
2022-09-29 23:46:37 +02:00
mv antos/frontend/master antos/frontend/latest
2022-09-29 23:49:17 +02:00
# clean up servies
find antos/ -name "systemd" -exec rm -rv {} +;
# header files
find antos/ -name "include" -exec rm -rv {} +;
# .la files
find antos/ -name "*.la" -type f -delete
2022-09-29 23:25:49 +02:00
tree antos
2022-09-29 21:31:29 +02:00
'''
2022-09-20 14:51:40 +02:00
}
}
2022-09-20 11:44:57 +02:00
stage('Build AMD64') {
steps {
2022-09-29 21:30:24 +02:00
sh'''
2022-09-20 14:21:09 +02:00
cd $WORKSPACE
2022-09-29 23:42:59 +02:00
for file in antos/frontend/*; do
2022-09-20 14:21:09 +02:00
echo "Building for AMD64 version $tag"
./mkimg.sh amd64 $(basename $file)
done
'''
2022-09-20 11:44:57 +02:00
}
}
2022-09-20 14:21:09 +02:00
stage('Build arm64') {
2022-09-20 11:44:57 +02:00
steps {
2022-09-29 21:30:24 +02:00
sh'''
2022-09-20 14:21:09 +02:00
cd $WORKSPACE
2022-09-29 23:42:59 +02:00
for file in antos/frontend/*; do
2022-09-20 14:21:09 +02:00
echo "Building for arm64 version $tag"
./mkimg.sh arm64 $(basename $file)
done
'''
2022-09-20 11:44:57 +02:00
}
}
2022-09-20 14:21:09 +02:00
stage('Build arm') {
2022-09-20 11:44:57 +02:00
steps {
2022-09-29 21:30:24 +02:00
sh'''
2022-09-20 14:21:09 +02:00
cd $WORKSPACE
2022-09-29 23:42:59 +02:00
for file in antos/frontend/*; do
2022-09-20 14:21:09 +02:00
echo "Building for arm version $tag"
./mkimg.sh arm $(basename $file)
done
'''
2022-09-20 11:44:57 +02:00
}
}
stage('Archive') {
steps {
script {
archiveArtifacts artifacts: 'build/', fingerprint: true
}
2023-01-01 12:11:45 +01:00
sh'''
2023-01-03 17:45:00 +01:00
cp -rf build/* /home/dany/public/antos-release/binaries
2023-01-01 12:11:45 +01:00
'''
2022-09-20 11:44:57 +02:00
}
}
}
2022-09-20 11:41:59 +02:00
}