在linux上电子版本无法定期创建rpm包

问题描述

使用Electron和ElectronNet我有一个蔚蓝的devops管道设置,它将使用*-latest映像在Linux,Windows和osx上构建应用程序。在Linux上,其配置为同时输出rpmdeb软件包,但是rpm软件包将无法使用该输出定期生成。发生这种情况时,通常会发生一段时间,然后在没有任何干预的情况下停止发生。第二天,我什至重新运行了失败的作业,并且在rpm和deb构建中构建都完全成功。 Deb构建从未失败。

一直在寻找有关如何使其始终获得成功或出了什么问题的想法。我的搜索功能尚未真正有用。


 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\",\"_topdir /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616\",\"_sourcedir /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616\",\"_rpmdir /tmp/package-rpm-build-72bf79147c0f3c704c50ec33b5227ad320ace97152807fea175c575ab616/RPMS\",\"_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

解决方法

发生这种情况是因为还使用了GitVersion版本,并且电子构建器使用FullSemVer参数将--iteration变量传递给了fpm命令。当正在构建的分支具有语义上适当的标记时(例如:1.2.3),FullSemVer看起来像1.2.3.0。但是,如果分支没有这样的标签,则它看起来像1.2.3-beta.1+1,并且由于非法字符而导致rpm构建失败。

要解决此问题,我将迭代参数硬编码到electron.manifest.json

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

,然后在电子构建之前添加任务以在构建之前更新值。

- 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...