forked from jenkinsci/packaging
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
30 changed files
with
1,014 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/tools/helpers.ps1 | ||
/legal/VERIFICATION.txt | ||
*.nupkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# chocolatey-jenkins | ||
Chocolatey packaging for Jenkins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
msiext-1.5/ | ||
msiext-1.5.zip | ||
packages/ | ||
tmp/ |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.