def build_moquitto() { sh ''' set -e DESTDIR="$WORKSPACE/build/$arch/" [ -d "$DESTDIR" ] && rm -rf "$DESTDIR" || true mkdir -p "$DESTDIR" # build libwebsocket first cd $WORKSPACE [ -d libwebsockets/build/ ] && rm -rf libwebsockets/build/ || true mkdir -p libwebsockets/build/ cd libwebsockets/build/ cmake -DLWS_WITH_EXTERNAL_POLL=ON -DLWS_WITH_STATIC=1 -DLWS_WITH_SHARED=0 .. make # now build moquitto cd $WORKSPACE/mosquitto make reallyclean || true make WITH_WEBSOCKETS=yes \ WITH_CJSON=no \ WITH_SHARED_LIBRARIES=no \ WITH_SYSTEMD=no \ WITH_DOCS=no \ CFLAGS="-I $WORKSPACE/libwebsockets/build/include/" \ LDFLAGS="-L $WORKSPACE/libwebsockets/build/lib" # install neccessary file mkdir -p "$DESTDIR/opt/www/bin/" mkdir -p "$DESTDIR/opt/www/config/" cp ./src/mosquitto $DESTDIR/opt/www/bin/ cp ./apps/mosquitto_passwd/mosquitto_passwd $DESTDIR/opt/www/bin/ cp ./mosquitto.conf $DESTDIR/opt/www/config/ ''' } pipeline{ agent { node{ label'master' }} options { 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('git init') { steps { sh''' cd $WORKSPACE git submodule update --init --depth 1 ''' } } stage('Build AMD64') { agent { docker { image 'xsangle/ci-tools:bionic-amd64' reuseNode true } } steps { script{ env.arch = "amd64" } build_moquitto() } } stage('Build ARM64') { agent { docker { image 'xsangle/ci-tools:bionic-arm64' reuseNode true } } steps { script{ env.arch = "arm64" } build_moquitto() } } stage('Build ARM') { agent { docker { image 'xsangle/ci-tools:bionic-arm' reuseNode true } } steps { script{ env.arch = "arm" } build_moquitto() } } stage('Archive') { steps { script { archiveArtifacts artifacts: 'build/', fingerprint: true } } } } }