0

I'm using Jenkins to build packages for Debian and Ubuntu. The new Raspberry PI nodes was added into my setup to build packages for Raspbian:

Jenkins Buildfarm in Action

The problem is how to make pipeline which build noarch package on any node and binary package on nodes for each architecture ?

I'm using patched docker image for each distribution to build package and perform test install for Debian 10-11 and Ubuntu 20.04-21.04. The armel/aarch64 versions of debian images also present on its Raspberry 3/4 nodes.

By default Jenkins pick one of nodes and triger build on it.

    stages {

        stage('debian-buster') {
            agent {
                docker { image 'vitexsoftware/debian:buster' }
            }
            steps {
                dir('build/debian/package') {
                    checkout scm
                buildPackage()
                installPackages()
                }
                stash includes: 'dist/**', name: 'dist-buster'
            }
            post {
                success {
                    archiveArtifacts 'dist/debian/'
                    copyArtifact()
                }
            }
        }
...   
  • How i can specify some architecture axe for build ?
  • Can i use jenkins node labels somehow ?

Early rack

Cybervitexus
  • 291
  • 4
  • 19

1 Answers1

0

There is not way how to solve this problem using Declarative Pipeline.

The scripted pipeline do the stuff:


#!groovy
String[] architectures = ['amd64', 'armhf', 'aarch64']
String[] distributions = ['debian:buster', 'debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:hirsute', 'ubuntu:impish']

String vendor = 'vitexsoftware'
String distribution = ''
String architecture = ''
String dockerfile = ''
String buildArgs = ''

architectures.each {
    architecture = it
    distributions.each {
        distribution = it
        dockerfile =  distribution + '/Dockerfile'
        buildArgs = ' --platform linux/' + architecture +
/*        ' -t ' + vendor + '/' + distribution + */
        ' -f ' + dockerfile + ' ' + distribution

        def buildImage = ''

        node( architecture ) {
            ansiColor('xterm') {
                stage('Build ' + architecture + '/' + distribution) {
                    checkout scm
                    buildImage = docker.build(vendor + '/' + distribution, buildArgs)
                }
                stage('Test ' + architecture + '/' + distribution) {
                    buildImage.inside {
                        sh 'whoami'
                        sh 'sudo apt install -y linuxlogo'
                        sh 'linuxlogo'
                    }
                }
                stage('Docker push ' + architecture + '/' + distribution ) {
                    docker.withRegistry('https://registry.hub.docker.com', 'vitex_dockerhub') {
                        buildImage.push(  distribution + "-${env.BUILD_NUMBER}-SNAPSHOT")
                    }
                }
            }
        }
    }
}

[![Jenkins Buildfarm in Action][1]][1]
Cybervitexus
  • 291
  • 4
  • 19