在 linux 上构建的电子无法定期创建 rpm 包
electron build on linux fails to create an rpm package periodically
使用 Electron 和 ElectronNet 我有一个 azure devops 管道设置,它将使用 *-latest
图像在 linux、windows 和 osx 上构建应用程序。在 linux 上,它配置为同时输出 rpm
和 deb
包,但是定期使用此输出构建 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\", \"--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
发生这种情况是因为还使用了 GitVersion 版本,并且 electron-builder 使用 --iteration
参数将 FullSemVer
变量传递给 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
使用 Electron 和 ElectronNet 我有一个 azure devops 管道设置,它将使用 *-latest
图像在 linux、windows 和 osx 上构建应用程序。在 linux 上,它配置为同时输出 rpm
和 deb
包,但是定期使用此输出构建 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\", \"--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
发生这种情况是因为还使用了 GitVersion 版本,并且 electron-builder 使用 --iteration
参数将 FullSemVer
变量传递给 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