Quantcast
Channel: Jenkins Blog
Viewing all articles
Browse latest Browse all 1087

How to build an unsigned Jenkins MSI on your Windows machine

$
0
0

Should you ever need to rebuild a Jenkins MSI on your Windows machine, here is a way to do it.

Pre-requisites

Jenkins WAR file

First, you should download the Jenkins war file that will be inside the MSI file. You can access it from the official Jenkins website or from the Jenkins update center.

Check the Jenkins download page to download the latest weekly version of Jenkins for example. You can always access the direct link to get the latest weekly version, but you won’t necessarily know which version number you are using. Just saying.

Git

There are quite a few ways to install Git on Windows, but the most straightforward way is to see what the official Git website recommends.

Install MSBuild

You can install MSBuild from Visual Studio or from the Build Tools for Visual Studio.

This command line tool is used to build the MSI file.

Install .NET Framework 3.5

You may already have it installed on your machine, but not activated. You can activate it from the Windows Features dialog box.

To access this dialog box, press the keys ⊞ Win + R, then enter the command appwiz.cpl and push enter. Search for

Turn Windows features on or off.

Tick the .NET Framework 3.5 entry and install.

now run Windows Update to check for security updates.

If it is not installed yet, you can install .NET Framework 3.5 from the Windows Features.

Check if you have PowerShell

In recent versions of Windows, PowerShell is already installed and accessible through the terminal application. At the time of writing, the pre-installed version is 5.1.22621.963. You can also install the latest version from the Microsoft Store (7.3.2 at the time of writing).

You could also install PowerShell from GitHub by issuing the following command:

wingetshow"Microsoft.PowerShell"-swinget

This would give an output similar to:

FoundPowerShell[Microsoft.PowerShell]Version:7.3.2.0Publisher:MicrosoftCorporationPublisherUrl:https://github.com/PowerShell/PowerShell/PublisherSupportUrl:https://github.com/PowerShell/PowerShell/issuesAuthor:MicrosoftCorporationMoniker:pwshDescription:PowerShellisacross-platform(Windows,Linux,andmacOS)automationandconfigurationtool/frameworkthatworkswellwithyourexistingtoolsandisoptimizedfordealingwithstructureddata(e.g.JSON,CSV,XML,etc.),RESTAPIs,andobjectmodels.Itincludesacommand-lineshell,anassociatedscriptinglanguageandaframeworkforprocessingcmdlets.Homepage:https://microsoft.com/PowerShellLicense:MITLicenseUrl:https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txtCopyright:Copyright(c)MicrosoftCorporationCopyrightUrl:https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txtReleaseNotesUrl:https://github.com/PowerShell/PowerShell/releases/tag/v7.3.2Tags:command-linecross-platformopen-sourcepowershellpwshshellInstaller:InstallerType:wixInstallerUrl:https://github.com/PowerShell/PowerShell/releases/download/v7.3.2/PowerShell-7.3.2-win-x64.msiInstallerSHA256:a4f7d081c5f74bc8d6c75f1dfee382b7fd9335361181748fee590ecdbc96cb26ReleaseDate:2023-01-24

You can see that the latest version is 7.3.2 and that the installer is a .msi file located on GitHub. Just follow the link provided with your browser and install PowerShell from this file once it has downloaded.

Build the MSI

Clone the Jenkins packaging repository

Choose your git tool and clone the Jenkins packaging repository on your machine.

Prepare the build

Open a terminal window and go to the folder where you cloned the repository. For example C:\jenkinsci\packaging\. You now have to declare where you downloaded the Jenkins war file, so the build script can find it.

$env:War="$env:USERPROFILE\jenkins.war"

If you have previously moved it into your repository clone folder, you can use this command instead:

$env:War="C:\jenkinsci\packaging\msi\build\jenkins.war"

Build the MSI

Enter the subfolder msi\build and run the following command:

.\build.ps1

You should get an output similar to:

ExtractingcomponentsJenkinsVersion=2.392RestoringpackagesbeforebuildAllpackageslistedinpackages.configarealreadyinstalled.BuildingMSIMSBuildversion17.4.0+18d5aef85for.NETFrameworkBuildstarted01/12/202220:53:30.Project"C:\jenkinsci\packaging\msi\build\jenkins.wixproj"onnode1(defaulttargets).SetConstants:EncodedVersion=2.255.3920Compile:Skippingtarget"Compile"becausealloutputfilesareup-to-datewithrespecttotheinputfiles.AssignCultures:Culture:en-USLink:C:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\Light.exe-outC:\jenkinsci\packaging\msi\build\bin\Release\en-US\jenkins-2.392.msi-pdboutC:\jenkinsci\packaging\msi\build\bin\Release\en-US\jenkins-2.392.wixpdb-sw1076-cultures:en-US-extC:\Support\users\jenkinsci\packaging\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixUIExtension.dll-extC:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixNetFxExtension.dll-extC:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixUtilExtension.dll-ext.\msiext-1.5\WixExtensions\WixCommonUIExtension.dll-extC:\jenkinsci\packaging\msi\build\packages\WiX.3.11.1\build\..\tools\\WixFirewallExtension.dll-fv-locjenkins_en-US.wxl-spdb-contentsfileobj\Release\jenkins.wixproj.BindContentsFileListen-US.txt-outputsfileobj\Release\jenkins.wixproj.BindOutputsFileListen-US.txt-builtoutputsfileobj\Release\jenkins.wixproj.BindBuiltOutputsFileListen-US.txt-wixprojectfileC:\jenkinsci\packaging\msi\build\jenkins.wixprojobj\Release\jenkins.wixobjWindowsInstallerXMLToolsetLinkerversion3.11.1.2318Copyright(c).NETFoundationandcontributors.Allrightsreserved.jenkins->C:\jenkinsci\packaging\msi\build\bin\Release\en-US\jenkins-2.392.msiDoneBuildingProject"C:\jenkinsci\packaging\msi\build\jenkins.wixproj"(defaulttargets).Buildsucceeded.0Warning(s)0Error(s)TimeElapsed00:00:08.26

Locate the generated MSI file

The MSI file is located in the .\bin\Release\en-US\ folder. In this folder, you will find the generated MSI file and its sha256 file.

lsDirectory:C:\jenkinsci\packaging\msi\build\bin\Release\en-USModeLastWriteTimeLengthName----------------------------a----01/12/202220:53105107456jenkins-2.392.msi-a----01/12/202220:5384jenkins-2.392.msi.sha256

Viewing all articles
Browse latest Browse all 1087

Trending Articles