electron build on linux fails to create an rpm package periodically

2.1k views Asked by At

Using Electron and ElectronNet I have an azure devops pipeline setup that will build the application on linux, windows and osx using the *-latest images to build. On linux its configured to output both an rpm and deb package however periodically the rpm package will fail to build with this output. When this happens it usually happens for a period of time and then stops happening without any intervention. I've even rerun the failed job the next day and the build is fully successful in both the rpm and deb builds. The deb build has never failed.

Really looking for any ideas on how to get it to be successful all the time or whats going wrong. My search-fu hasn't really turned up anything useful.


 Package Electron App for Platform linux...
    • electron-builder  version=22.8.1 os=5.4.0-1026-azure
    • artifacts will be published if draft release exists  reason=CI detected
    • loaded configuration  file=/home/vsts/work/1/s/src/Prefix.App/obj/desktop/-encodedCommand/bin/electron-builder.json
    • description is missed in the package.json  appPackageFile=/home/vsts/work/1/s/src/Prefix.App/obj/desktop/-encodedCommand/package.json
    • packaging       platform=linux arch=x64 electron=9.2.0 appOutDir=/home/vsts/work/1/s/dist/linux-unpacked
    • downloading     url=https://github.com/electron/electron/releases/download/v9.2.0/electron-v9.2.0-linux-x64.zip size=73 MB parts=4
    • downloaded      url=https://github.com/electron/electron/releases/download/v9.2.0/electron-v9.2.0-linux-x64.zip duration=1.841s
    • building        target=deb arch=x64 file=/home/vsts/work/1/s/dist/stackify-prefix.deb
    • application Linux category is set to default "Utility"  reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
    • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86_64/fpm-1.9.3-2.3.1-linux-x86_64.7z size=5.0 MB parts=1
    • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86_64/fpm-1.9.3-2.3.1-linux-x86_64.7z duration=798ms
    • building        target=rpm arch=x64 file=/home/vsts/work/1/s/dist/stackify-prefix.rpm
    • application Linux category is set to default "Utility"  reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux
    ⨯ cannot execute  cause=exit status 1
                      out={:timestamp=>"2020-10-08T17:32:40.544179+0000", :message=>"Process failed: rpmbuild failed (exit code 1). Full command was:[\"rpmbuild\", \"-bb\", \"--target\", \"x86_64-unknown-linux\", \"--define\", \"buildroot /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616/BUILD\", \"--define\", \"_topdir /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616\", \"--define\", \"_sourcedir /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616\", \"--define\", \"_rpmdir /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616/RPMS\", \"--define\", \"_tmppath /tmp\", \"/tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616/SPECS/Prefix.spec\"]", :level=>:error}
                      command=/home/vsts/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86_64/fpm -s dir --force -t rpm -d libXScrnSaver --rpm-os linux --rpm-compression xzmt --architecture amd64 --name prefix --after-install /tmp/t-KD6Fyh/2-after-install --after-remove /tmp/t-KD6Fyh/3-after-remove --description '' --version 1.0.0 --package /home/vsts/work/1/s/dist/stackify-prefix.rpm --maintainer Stackify --url 'https://github.com/ElectronNET/Electron.NET#readme' --vendor Stackify --license MIT --iteration 0.8.25-rc.1+72 --name=Prefix --after-install=../../../../../build/linux/postinst --after-remove=../../../../../build/linux/postrm /home/vsts/work/1/s/dist/linux-unpacked/=/opt/Prefix /home/vsts/work/1/s/build/assets/Prefix_256.png=/usr/share/icons/hicolor/0x0/apps/Prefix.png /tmp/t-KD6Fyh/5-Prefix.desktop=/usr/share/applications/Prefix.desktop
                      workingDir=
 ... done
1

There are 1 answers

0
danatcofo On BEST ANSWER

This happened because GitVersion version is also used and electron-builder passes the FullSemVer variable to the fpm command using the --iteration argument. When the branch being built had a semantically appropriate tag, (example: 1.2.3) the FullSemVer looked like 1.2.3.0. However if the branch didn't have such a tag it looked like 1.2.3-beta.1+1 and the rpm build failed because of illegal characters.

To fix this I hardcoded the iteration argument into the electron.manifest.json

   "rpm": {
      "fpm": [
        "--iteration=1.0.0"
      ]
    }

and then added a task prior to the electron build to update the value prior to build.

- pwsh: |
   $variable = '--iteration=' + $env:GITVERSION_MAJORMINORPATCH
   (Get-Content -Path .\path\to\electron.manifest.json -Raw) -replace '--iteration=1.0.0', $variable | Set-Content -Path .\path\to\electron.manifest.json