Skip to content

Commit

Permalink
(jenkins) Adds Jenkins package
Browse files Browse the repository at this point in the history
  • Loading branch information
JPRuskin committed Nov 15, 2022
1 parent 2324e81 commit 62eafb0
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 0 deletions.
29 changes: 29 additions & 0 deletions automatic/jenkins/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ![Jenkins Logo](https://cdn.jsdelivr.net/gh/pauby/chocopackages@ae92e032839a27a3633db7018593b075df44269f/icons/jenkins.png "Jenkins Logo") [Jenkins](https://chocolatey.org/packages/jenkins)

This is the LTS version of Jenkins.

Jenkins is an open source automation server which enables developers around the world to reliably build, test, and deploy their software.

* Continuous Integration and Continuous Delivery
As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.

* Easy installation
Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems.

* Easy configuration
Jenkins can be easily set up and configured via its web interface, which includes on-the-fly error checks and built-in help.

* Plugins
With hundreds of plugins in the Update Center, Jenkins integrates with practically every tool in the continuous integration and continuous delivery toolchain.

* Extensible
Jenkins can be extended via its plugin architecture, providing nearly infinite possibilities for what Jenkins can do.

* Distributed
Jenkins can easily distribute work across multiple machines, helping drive builds, tests and deployments across multiple platforms faster.

**NOTE**: You need Java JRE 11 for Jenkins to install. This has not been added as a dependency as there are so many flavours. The package used in testing was `termurin11jre` but others should work without issue. If the package cannot find a `JAVA_HOME` environment variable, or find a JRE folder in Program Files, the package will fail out. You can pass `JAVA_HOME` manually as follows:

`choco install jenkins --parameters="/JAVA_HOME='C:\Program Files\InstalledJRE\'"`

**NOTE**: This is an automatically updated package. If you find it is out of date by more than a week, please contact the maintainer(s) and let them know the package is no longer updating correctly.
57 changes: 57 additions & 0 deletions automatic/jenkins/jenkins.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>jenkins</id>
<version>2.222.4</version>
<packageSourceUrl>https://github.com/git@github.com:chocolatey-community/chocolatey-packages/tree/master/automatic/jenkins</packageSourceUrl>
<owners>pauby,johnypony3</owners>
<title>Jenkins CI</title>
<authors>Kohsuke Kawaguchi</authors>
<projectUrl>https://www.jenkins.io/</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/git@github.com:chocolatey-community/chocolatey-packages/icons/jenkins.png</iconUrl>
<copyright>2018 Kohsuke Kawaguchi</copyright>
<licenseUrl>https://github.com/jenkinsci/jenkins/blob/master/LICENSE.txt</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/jenkinsci/jenkins</projectSourceUrl>
<docsUrl>https://www.jenkins.io/doc</docsUrl>
<bugTrackerUrl>https://github.com/jenkinsci/jenkins/issues</bugTrackerUrl>
<tags>ci</tags>
<summary>Jenkins is an open source automation server which enables developers around the world to reliably build, test, and deploy their software.</summary>
<description><![CDATA[This is the LTS version of Jenkins.
Jenkins is an open source automation server which enables developers around the world to reliably build, test, and deploy their software.
* Continuous Integration and Continuous Delivery
As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.
* Easy installation
Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems.
* Easy configuration
Jenkins can be easily set up and configured via its web interface, which includes on-the-fly error checks and built-in help.
* Plugins
With hundreds of plugins in the Update Center, Jenkins integrates with practically every tool in the continuous integration and continuous delivery toolchain.
* Extensible
Jenkins can be extended via its plugin architecture, providing nearly infinite possibilities for what Jenkins can do.
* Distributed
Jenkins can easily distribute work across multiple machines, helping drive builds, tests and deployments across multiple platforms faster.
**NOTE**: You need Java JRE 11 for Jenkins to install. This has not been added as a dependency as there are so many flavours. The package used in testing was `termurin11jre` but others should work without issue. If the package cannot find a `JAVA_HOME` environment variable, or find a JRE folder in Program Files, the package will fail out. You can pass `JAVA_HOME` manually as follows:
`choco install jenkins --parameters="/JAVA_HOME='C:\Program Files\InstalledJRE\'"`
**NOTE**: This is an automatically updated package. If you find it is out of date by more than a week, please contact the maintainer(s) and let them know the package is no longer updating correctly.
]]></description>
<releaseNotes>http://jenkins-ci.org/changelog</releaseNotes>
<dependencies>
<!-- dependency id="temurin11jre" / -->
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
23 changes: 23 additions & 0 deletions automatic/jenkins/tools/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From: https://github.com/jenkinsci/jenkins/blob/master/LICENSE.txt

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.
8 changes: 8 additions & 0 deletions automatic/jenkins/tools/VERIFICATION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community in verifying that this package's contents are trustworthy.

To verify the files using the project source:

1. Please go to the Jenkins mirrors page for Windows - http://mirrors.jenkins-ci.org/windows-stable/
2. Click the version of the file or folder that matches this package version;
3. Use Get-FileHash -Path <FILE TO VERIFY> to get the file hash value from both the built file (from the steps above) and the file from the package and compare them;
3 changes: 3 additions & 0 deletions automatic/jenkins/tools/chocolateyBeforeModify.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (Get-Service Jenkins -ErrorAction SilentlyContinue) {
Stop-Service Jenkins
}
105 changes: 105 additions & 0 deletions automatic/jenkins/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
$ErrorActionPreference = 'Stop'

# Set all passed package parameters as variables
(Get-PackageParameters).GetEnumerator().ForEach{
Set-Variable -Name $_.Key -Value $_.Value
}

$ToolsDir = Split-Path -parent $MyInvocation.MyCommand.Definition
$JenkinsRegistryRoot = "HKLM:\SOFTWARE\Jenkins\InstalledProducts\Jenkins"

# If x86 exists, that is the default installation location for the previous version of Jenkins on an x64 system
$ProgramFiles = @($env:ProgramFiles, ${env:ProgramFiles(x86)})[[bool]${env:ProgramFiles(x86)}]
$MsiUpgrade = -not (Test-Path $JenkinsRegistryRoot) -and
(Test-Path $ProgramFiles\Jenkins\jenkins.exe) -and
[version](Get-ItemProperty $ProgramFiles\Jenkins\jenkins.exe -ErrorAction SilentlyContinue).VersionInfo.ProductVersion -le "2.3.0"

if (-not $env:JAVA_HOME -and -not $JAVA_HOME) {
if ($JavaPath = Convert-Path "$env:ProgramFiles\*\jre-11*") {
Write-Verbose "Found '$JavaPath', using '$(@($JavaPath)[0])'"
$JAVA_HOME = @($JavaPath)[0]
} else {
throw 'Jenkins will fail to install if Java is not available. Pass the JAVA_HOME as a param or ensure $env:JAVA_HOME is set.'
}
}

$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'msi'
file = Join-Path $ToolsDir 'jenkins.msi'
silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($env:ChocolateyPackageName).$($env:chocolateyPackageVersion).MsiInstall.log`""
validExitCodes= @(0, 3010, 1641)
softwareName = 'Jenkins*'
}

if ($INSTALLDIR) {
$packageArgs.silentArgs += " INSTALLDIR=`"$($INSTALLDIR)`""
}

if ($JENKINS_ROOT) {
$packageArgs.silentArgs += " JENKINS_ROOT=`"$($JENKINS_ROOT)`""

if ($CurrentRoot = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Jenkins\InstalledProducts\Jenkins" -Name JenkinsRoot -ErrorAction SilentlyContinue).JenkinsRoot) {
Write-Warning "The Jenkins Msi Installer does not support changing JENKINS_ROOT after installation. JENKINS_ROOT is currently set to '$($CurrentRoot)'"
}
} elseif (-not (Get-ItemProperty -Path "HKLM:\SOFTWARE\Jenkins\InstalledProducts\Jenkins" -Name JenkinsRoot -ErrorAction SilentlyContinue)) {
$packageArgs.silentArgs += " JENKINS_ROOT=`"$env:ProgramData\Jenkins\`""
}

if ($PORT) {
$packageArgs.silentArgs += " PORT=$($PORT)"
}

if ($JAVA_HOME) {
$packageArgs.silentArgs += " JAVA_HOME=`"$($JAVA_HOME)`""
}

if ($SERVICE_USERNAME) {
$packageArgs.silentArgs += " SERVICE_USERNAME=`"$($SERVICE_USERNAME)`""
}

if ($SERVICE_PASSWORD) {
$packageArgs.silentArgs += " SERVICE_PASSWORD=`"$($SERVICE_PASSWORD)`""
}

Install-ChocolateyInstallPackage @packageArgs

<# This logic is here to deal with upgrades from the MSI installer for 2.222 to the newer 2.3* #>
if ($MsiUpgrade) {
$PreviousDataDirectory = Convert-Path $ProgramFiles\Jenkins\
$NewDataDirectory = $(cmd /c "echo $(([xml](Get-Content $env:ProgramFiles\Jenkins\jenkins.xml)).service.env.value)")

# Installing the new MSI should have uninstalled the application data for Jenkins 2.3.0 without removing user data
Write-Warning "Migrating Jenkins 2.3.0 Data from '$($PreviousDataDirectory)' to '$($NewDataDirectory)' (Copy Only)"
Stop-Service -Name Jenkins -Force

if (-not (Test-Path $NewDataDirectory)) {
$null = New-Item -Path $NewDataDirectory -ItemType Directory -Force
}

foreach ($Item in @(
"jobs"
"nodes"
"plugins"
"secrets"
"userContent"
"users"
"identity.key.enc"
"secret.key"
"secret.key.not-so-secret"
"credentials.xml"
"jenkins.install.InstallUtil.installingPlugins"
"jenkins.install.InstallUtil.lastExecVersion"
"jenkins.install.UpgradeWizard.state"
"jenkins.model.JenkinsLocationConfiguration"
)) {
Remove-Item -Path (Join-Path $NewDataDirectory $Item) -Recurse -ErrorAction SilentlyContinue
Copy-Item -Path (Join-Path $PreviousDataDirectory $Item) -Destination $NewDataDirectory -Recurse -ErrorAction SilentlyContinue
}

if (-not (Test-Path $PreviousDataDirectory\secrets\initialAdminPassword) -and (Test-Path $NewDataDirectory\secrets\initialAdminPassword)) {
Rename-Item $NewDataDirectory\secrets\initialAdminPassword -NewName "initialAdminPassword.backup"
}
}

Start-Service Jenkins
37 changes: 37 additions & 0 deletions automatic/jenkins/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#requires -Modules au
param(
# The URL to search for information on the latest release
$ReleasePage = "https://www.jenkins.io/download/",

# The regex used to search for the latest version on the ReleasePage
$ReleaseRegex = "Download Jenkins`n(?<Version>[\d\.]+)`nLTS",

# The base of the download URL
$DownloadURL = "http://mirrors.jenkins-ci.org/windows-stable/"
)

function global:au_BeforeUpdate {
Get-RemoteFiles -Purge -NoSuffix
}

function global:au_SearchReplace {
@{}
}

function global:au_GetLatest {
if ((Invoke-WebRequest -Uri $ReleasePage -UseBasicParsing).RawContent -match $ReleaseRegex) {
$LatestVersion = $Matches.Version
@{
Version = $LatestVersion
URL64 = "$($DownloadURL.TrimEnd('/'))/$LatestVersion/jenkins.msi"
TagName = $tagName
}
} else {
Write-Error "Could not find a version of Jenkins on '$($ReleasePage)' (with regex '$($ReleaseRegex)')" -ErrorAction Stop
}
}

if ($MyInvocation.InvocationName -ne '.') {
# run the update only if script is not sourced
update -ChecksumFor none
}
Binary file added icons/jenkins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 62eafb0

Please sign in to comment.