antos-deb/Jenkinsfile

136 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

2023-01-01 12:35:27 +01:00
// need to approve all static functions in Dashboard > Manage Jenkins > ScriptApproval
// 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
// staticMethod jenkins.model.Jenkins getInstance
def ArrayList<String> getBranches(projectName){
def jobs = jenkins.model.Jenkins.instance.getItemByFullName(projectName).getAllJobs();
Iterator<?> iterator = jobs.iterator();
def arr = new ArrayList<String>();
while (iterator.hasNext()) {
def job = iterator.next();
arr.add(job.getName());
}
return arr;
}
def generateStage(name) {
return {
2023-01-01 13:01:30 +01:00
stage("ANTOS ${name}") {
2023-01-01 12:56:51 +01:00
env.tag = name;
sh'''
2023-01-01 14:21:42 +01:00
echo "Build AntOS deb package for version $tag on architecture $arch"
2023-01-01 12:56:51 +01:00
set -e
set -x
2023-01-01 14:21:42 +01:00
./build_deb.sh $tag $arch
2023-01-01 12:56:51 +01:00
'''
2023-01-01 12:35:27 +01:00
}
}
}
def parallelStagesMap = getBranches("gitea-sync/antos").collectEntries {
["${it}" : generateStage(it)]
}
pipeline{
2023-01-01 15:13:02 +01:00
agent { node{ label'workstation' }}
2023-01-01 12:35:27 +01: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
{
stage('Prepare binaries') {
steps {
sh'''
[ -d build ] && rm -rf build
mkdir build
[ -d antos ] && rm -rf antos
2023-01-01 12:38:39 +01:00
mkdir antos
2023-01-01 12:35:27 +01:00
'''
copyArtifacts(projectName: 'gitea-sync/antos-appimage/master', target: 'antos/');
sh'''
2023-01-01 13:07:40 +01:00
ls -al antos
2023-01-01 12:35:27 +01:00
'''
}
2023-01-01 13:02:53 +01:00
}
stage("AMD64") {
agent {
docker {
image 'xsangle/ci-tools:bionic-amd64'
reuseNode true
2023-01-01 13:01:30 +01:00
}
2023-01-01 13:02:53 +01:00
}
steps {
2023-01-01 13:01:30 +01:00
2023-01-01 13:02:53 +01:00
script
{
2023-01-01 13:05:26 +01:00
env.arch = "x86_64";
2023-01-01 13:02:53 +01:00
parallel parallelStagesMap;
2023-01-01 13:01:30 +01:00
}
}
2023-01-01 13:02:53 +01:00
}
2023-01-01 13:01:30 +01:00
2023-01-01 13:02:53 +01:00
stage("ARM64") {
agent {
docker {
image 'xsangle/ci-tools:bionic-arm64'
reuseNode true
2023-01-01 13:01:30 +01:00
}
2023-01-01 13:02:53 +01:00
}
steps {
2023-01-01 13:01:30 +01:00
2023-01-01 13:02:53 +01:00
script
{
2023-01-01 13:05:26 +01:00
env.arch = "aarch64";
2023-01-01 13:02:53 +01:00
parallel parallelStagesMap;
2023-01-01 13:01:30 +01:00
}
}
2023-01-01 13:02:53 +01:00
}
2023-01-01 13:01:30 +01:00
2023-01-01 13:02:53 +01:00
stage("ARM") {
agent {
docker {
image 'xsangle/ci-tools:bionic-arm'
reuseNode true
2023-01-01 13:01:30 +01:00
}
2023-01-01 13:02:53 +01:00
}
steps {
script
{
2023-01-01 13:05:26 +01:00
env.arch = "armv7l";
2023-01-01 13:02:53 +01:00
parallel parallelStagesMap;
2023-01-01 13:01:30 +01:00
}
}
2023-01-01 12:35:27 +01:00
}
2023-01-01 15:10:57 +01:00
stage('Archive') {
steps {
script {
archiveArtifacts artifacts: 'build/', fingerprint: true
}
sh'''
2023-01-03 17:46:16 +01:00
cp -rf build/* /home/dany/public/antos-release/binaries/deb
2023-01-01 15:10:57 +01:00
'''
}
}
2023-01-01 12:35:27 +01:00
}
}