Skip to content

Commit

Permalink
[WIP] Update Windows installer
Browse files Browse the repository at this point in the history
- Add initial Chocolatey package
- Rework Windows installer to remove JRE
- Add branding images
- Add ability to select account, port and installation director
  • Loading branch information
slide committed Aug 27, 2019
1 parent c4c7373 commit e90c7fb
Show file tree
Hide file tree
Showing 30 changed files with 1,014 additions and 251 deletions.
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ clean:
setup:
bash -ex -c 'for f in */setup.sh; do $$f; done'

package: war msi deb rpm suse osx
package: war deb rpm suse osx

publish: war.publish msi.publish deb.publish rpm.publish suse.publish osx.publish
publish: war.publish deb.publish rpm.publish suse.publish osx.publish

test: deb.test rpm.test suse.test

Expand All @@ -47,14 +47,6 @@ war.publish: ${WAR}



msi: ${MSI}
${MSI}: ${WAR} ${CLI} $(shell find msi -type f)
./msi/build-on-jenkins.sh
msi.publish: ${MSI}
./msi/publish.sh



osx: ${OSX}
${OSX}: ${WAR} ${CLI} $(shell find osx -type f | sed -e 's/ /\\ /g')
./osx/build-on-jenkins.sh
Expand Down
3 changes: 3 additions & 0 deletions chocolatey/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/tools/helpers.ps1
/legal/VERIFICATION.txt
*.nupkg
21 changes: 21 additions & 0 deletions chocolatey/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Alex Earl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions chocolatey/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# chocolatey-jenkins
Chocolatey packaging for Jenkins
58 changes: 58 additions & 0 deletions chocolatey/jenkins.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata>
<id>$id$</id>
<version>2.121.3</version>
<title>Jenkins CI/CD Server</title>
<authors>Jenkins Community</authors>
<owners>jenkins</owners>
<licenseUrl>https://raw.githubusercontent.com/jenkinsci/jenkins/master/LICENSE.txt</licenseUrl>
<projectUrl>https://jenkins.io</projectUrl>
<docsUrl>https://jenkins.io/doc/</docsUrl>
<iconUrl>https://jenkins.io/images/logos/jenkins/jenkins.png</iconUrl>
<bugTrackerUrl>https://issues.jenkins-ci.org</bugTrackerUrl>
<releaseNotes>https://jenkins.io/$changelog$/#v$version$</releaseNotes>
<!--<packageSourceUrl>https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/automatic/apache-httpd</packageSourceUrl>-->
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.</summary>
<description><![CDATA[
## About
In a nutshell, Jenkins is the leading open-source automation server.
Built with Java, it provides over 1000 plugins to support automating virtually anything,
so that humans can actually spend their time doing things machines cannot.
## What to Use Jenkins for and When to Use It
Use Jenkins to automate your development workflow so you can focus on work that matters most. Jenkins is commonly used for:
- Building projects
- Running tests to detect bugs and other issues as soon as they are introduced
- Static code analysis
- Deployment
Execute repetitive tasks, save time, and optimize your development process with Jenkins.
## Package Parameters
* `/port` - The port Jenkins will listen to. Default: `8080`
Example: `choco install $id$ --params '"/port:433"'`
## Notes
* This package will install the latest Jenkins $releaseType$ binaries provided at the Jenkins website (https://jenkins.io/).
* Jenkins will be installed as a service under the default name 'Jenkins'
]]></description>
<tags>jenkins ci cd</tags>
<dependencies>
<dependency id="jre8" />
<dependency id="chocolatey" version="0.10.8" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="legal\**" target="legal" />
</files>
</package>
22 changes: 22 additions & 0 deletions chocolatey/legal/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2004-, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of other of contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

60 changes: 60 additions & 0 deletions chocolatey/mkrelease.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/pwsh
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[String] $JenkinsVersion,
[String] $SHA256Hash=''
)

$isLts = $JenkinsVersion.Split('.').Length -gt 2

if(Test-Path bin) {
Remove-Item -Recurse -Force bin
}

$currDir = Split-Path -parent $MyInvocation.MyCommand.Definition

$helperOutputFile = (Join-Path $currDir (Join-Path "tools" "helpers.ps1"))
if (Test-Path $helperOutputFile) {
Remove-Item -Force $helperOutputFile
}

$verificationOutputFile = (Join-Path $currDir (Join-Path "legal" "VERIFICATION.txt"))
if (Test-Path $verificationOutputFile) {
Remove-Item -Force $verificationOutputFile
}

$suffix = @("", "-stable")[$isLts]
$changelog = "changelog${suffix}"
$zipLoc = "windows${suffix}"
$releaseType = @("Weekly", "LTS")[$isLts]

if($JenkinsVersion -eq "") {
Write-Error "Missing version parameter!"
}

if($SHA256Hash -eq "") {
$shaUrl = "http://mirrors.jenkins-ci.org/$($zipLoc)/jenkins-$($JenkinsVersion).msi.sha256"
$shaFile = [System.IO.Path]::GetTempFileName()
Invoke-WebRequest -Uri $shaUrl -OutFile $shaFile
$shaContents = (Get-Content $shaFile)
$SHA256Hash = ($shaContents -split "\s+")[0]
}

$helpersFile = Get-Content (Join-Path $currDir (Join-Path "templates" "helpers.ps1.in"))
$helpersFile = $helpersFile -replace "%ZIP_LOC%", $zipLoc
$helpersFile = $helpersFile -replace "%CHECKSUM%", $SHA256Hash
Set-Content -Path $helperOutputFile -Value $helpersFile -Encoding Ascii

$verificationFile = Get-Content (Join-Path $currDir (Join-Path "templates" "VERIFICATION.txt.in"))
$verificationFile = $verificationFile -replace "%ZIP_LOC%", $zipLoc
$verificationFile = $verificationFile -replace "%CHECKSUM%", $SHA256Hash
$verificationFile = $verificationFile -replace "%VERSION%", $JenkinsVersion
Set-Content -Path $verificationOutputFile -Value $verificationFile -Encoding Ascii

if($null -eq (Get-Command choco.exe)) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}

mkdir -Confirm:$false bin | Out-Null
& choco pack --version="$JenkinsVersion" id="jenkins${suffix}" changelog="$changelog" releaseType="$releaseType" --out="bin"
17 changes: 17 additions & 0 deletions chocolatey/templates/VERIFICATION.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

The installer have been downloaded from their official download link listed on <https://jenkins.io/download/>
and can be verified like this:

1. Download the following installers:
<http://mirrors.jenkins-ci.org/%ZIP_LOC%/jenkins-%VERSION%.zip>
2. You can use one of the following methods to obtain the checksum
- Use powershell function 'Get-Filehash'
- Use chocolatey utility 'checksum.exe'

checksum type: sha256
checksum: %CHECKSUM%

File 'LICENSE.txt' is obtained from <https://raw.githubusercontent.com/jenkinsci/jenkins/master/LICENSE.txt>
119 changes: 119 additions & 0 deletions chocolatey/templates/helpers.ps1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
function Assert-TcpPortIsOpen {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline)][ValidateNotNullOrEmpty()][int] $portNumber
)

$process = Get-NetTCPConnection -State Listen -LocalPort $portNumber -ErrorAction SilentlyContinue | `
Select-Object -First 1 -ExpandProperty OwningProcess | `
Select-Object @{Name = "Id"; Expression = {$_} } | `
Get-Process | `
Select-Object Name, Path

if ($process) {
if ($process.Path) {
Write-Host "Port '$portNumber' is in use by '$($process.Name)' with path '$($process.Path)'..."
}
else {
Write-Host "Port '$portNumber' is in use by '$($process.Name)'..."
}

return $false
}

return $true
}

function Get-JenkinsPaths {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory)][ValidateNotNullOrEmpty()][string] $installDir
)

$jenkinsDir = Get-ChildItem $installDir -Directory -Filter 'Jenkins*' | Select-Object -First 1 -ExpandProperty FullName
$xmlPath = Join-Path $jenkinsDir 'jenkins.xml'
$binPath = Join-Path $jenkinsDir 'jenkins.exe'

$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry32)
$subKey = $key.OpenSubKey("Software\JavaSoft\Java Runtime Environment\1.8")
$javaHome = $subKey.GetValue("JavaHome")

return @{ JenkinsDir = $jenkinsDir; XmlPath = $xmlPath; BinPath = $binPath; JavaHome = $javaHome }
}

function Install-Jenkins {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory)][ValidateNotNullOrEmpty()][PSCustomObject] $arguments
)

$toolsDir = $arguments.toolsDir
$zipFile = "$toolsDir\jenkins-$($env:ChocolateyPackageVersion).zip"
$packageName = $arguments.packageName

Get-ChocolateyWebFile `
-PackageName "$packageName" `
-FileFullPath "$zipFile" `
-Url "http://mirrors.jenkins-ci.org/%ZIP_LOC%/jenkins-$($env:ChocolateyPackageVersion).zip" `
-Checksum '%CHECKSUM%' `
-ChecksumType 'sha256'

Get-ChocolateyUnzip `
-FileFullPath "$zipFile" `
-Destination $toolsDir

$installerFile = Join-Path $toolsDir 'jenkins.msi'

Install-ChocolateyInstallPackage `
-PackageName $packageName `
-FileType 'msi' `
-File "$installerFile" `
-SilentArgs "/qn /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`""

if(Get-OSArchitectureWidth -Compare 64) {
$arguments.destination = ${env:ProgramFiles(x86)}
} else {
$arguments.destinaton = $env:ProgramFiles
}

# stop the service so we can update the configuration
Stop-JenkinsService

Set-JenkinsConfig $arguments

Start-JenkinsService
}

function Set-JenkinsConfig {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory)][ValidateNotNullOrEmpty()][PSCustomObject] $arguments
)

$jenkinsPaths = Get-JenkinsPaths $arguments.destination
$jrePath = Join-Path $jenkinsPaths.JavaHome "bin\java.exe"

# Update the server root and port number
$xmlConf = Get-Content $jenkinsPaths.XmlPath
$xmlConf = $xmlConf -replace "%BASE%\\jre\\bin\\java", $jrePath
$xmlConf = $xmlConf -replace '%BASE%', $jenkinsPaths.JenkinsDir
$xmlConf = $xmlConf -replace '--httpPort=8080', "--httpPort=$($arguments.port)"

Set-Content -Path $jenkinsPaths.XmlPath -Value $xmlConf -Encoding Ascii
}

function Stop-JenkinsService {
$service = Get-Service | Where-Object Name -eq "Jenkins"

if ($service) {
Stop-Service "Jenkins"
}
}

function Start-JenkinsService {
$service = Get-Service | Where-Object Name -eq "Jenkins"

if ($service) {
Start-Service "Jenkins"
}
}
3 changes: 3 additions & 0 deletions chocolatey/tools/chocolateyBeforeModify.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
. (Join-Path (Split-Path -parent $MyInvocation.MyCommand.Definition) 'Helpers.ps1')

Stop-JenkinsService
19 changes: 19 additions & 0 deletions chocolatey/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$toolsDir = Split-Path -parent $MyInvocation.MyCommand.Definition
. "$toolsDir\helpers.ps1"

$pp = Get-PackageParameters

$arguments = @{
packageName = $env:chocolateyPackageName
file = "$toolsDir\jenkins.msi"
port = if ($pp.Port) { $pp.Port } else { 8080 }
serviceName = "Jenkins"
destination = ""
toolsDir = $toolsDir
}

if (-not (Assert-TcpPortIsOpen $arguments.port)) {
throw 'Please specify a different port number...'
}

Install-Jenkins $arguments
4 changes: 4 additions & 0 deletions msi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
msiext-1.5/
msiext-1.5.zip
packages/
tmp/
5 changes: 0 additions & 5 deletions msi/FindJava.java

This file was deleted.

Binary file added msi/License.rtf
Binary file not shown.
Binary file added msi/banner.bmp
Binary file not shown.
Loading

0 comments on commit e90c7fb

Please sign in to comment.