Nexus Repository OSS

  • 1
  • 2
  • 3

3.34.1.01 | Updated: 24 Sep 2021

Downloads:

13,576

Downloads of v 3.34.1.01:

256

Software Author(s):

  • Sonatype

  • 1
  • 2
  • 3
Nexus Repository OSS 3.34.1.01

  • 1
  • 2
  • 3

This Package Contains an Exempted Check

Not All Tests Have Passed


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Exemption for this package version only:

File too large to be scanned

Details

To install Nexus Repository OSS, run the following command from the command line or from PowerShell:

>

To upgrade Nexus Repository OSS, run the following command from the command line or from PowerShell:

>

To uninstall Nexus Repository OSS, run the following command from the command line or from PowerShell:

>

NOTE: This applies to both open source and commercial editions of Chocolatey.

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Enter your internal repository url

(this should look similar to https://community.chocolatey.org/api/v2)

4. Choose your deployment method:


choco upgrade nexus-repository -y --source="'STEP 3 URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade nexus-repository -y --source="'STEP 3 URL'"
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Ensure nexus-repository installed
  win_chocolatey:
    name: nexus-repository
    state: present
    version: 3.34.1.01
    source: STEP 3 URL

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'nexus-repository' do
  action    :install
  version  '3.34.1.01'
  source   'STEP 3 URL'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


Chocolatey::Ensure-Package
(
    Name: nexus-repository,
    Version: 3.34.1.01,
    Source: STEP 3 URL
);

Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.


cChocoPackageInstaller nexus-repository
{
   Name     = 'nexus-repository'
   Ensure   = 'Present'
   Version  = '3.34.1.01'
   Source   = 'STEP 3 URL'
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'nexus-repository':
  provider => 'chocolatey',
  ensure   => '3.34.1.01',
  source   => 'STEP 3 URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


salt '*' chocolatey.install nexus-repository version="3.34.1.01" source="STEP 3 URL"

See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.

5. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

This package is exempt from moderation. While it is likely safe for you, there is more risk involved.
Description

Free open source version of popular Nexus Repository for binary artifacts including first class Nuget support..
Free OSS version supports advanced access control (groups, roles), LDAP and per-user api keys.
Nexus product does not have a built-in web gallery for components.

ATTENTION BREAKING CHANGE FOR UPGRADES FROM VERSIONS BEFORE 3.3.2.02
Nexus no longer provided a setup.exe for installing Nexus Repository 3.x on Windows.
If you previously installed this with a package that used a setup.exe, you must manually uninstall it first (use choco uninstall nexus-repository if you used Chocolatey to install it). Once you are on 3.3.2.02 or later, upgrades will work smoothly.

This package supports the following parameters:

-params '"/Port:8081"' (default: 8081)
Specify what port Nexus should listen on.

-params "'/BackupSslConfig'"
Ensures that the ssl configuration survives an upgrade

-params "'/BackupLocation'"
Species the path to backup ssl configuration to during upgrade

-params "'/Fqdn" (default:hostname)
The fqdn that matches the subject you are using for your Nexus instance


tools\chocolateyinstall.ps1
$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$version = '3.34.1-01'
$url64 = 'https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.34.1-01-win64.zip'
$checksum64 = 'F6A4A86ADA609D756FB93757A8755AF72E0789B85823B6D5846E128537D9D477'
$checksumType64 = 'SHA256'
$validExitCodes = @(0)
Import-Module (Join-Path $toolsDir 'supportingfunctions.psm1')

$name = $env:Computername
$domainName = $env:USERDOMAIN

$hostName = if (-not $name.endswith($domainName)) {
  "$name.$domainName"
}
else {
  $name
}

$packageName = $env:ChocolateyPackagename

$osBits = Get-ProcessorBits

If (!($osBits -eq 64)) {
  Throw "Sonatype Nexus Repository 3.0 and greater only supports 64-bit Windows."
}

$nexusVersionedFolder = "nexus-$version"
$targetFolder = "$env:programdata\nexus"
$extractFolder = "$env:temp\NexusExtract"
$targetDataFolder = "$env:programdata\sonatype-work"
$nexusConfigFile = "$TargetDataFolder\nexus3\etc\nexus.properties"
$serviceName = 'nexus'
$nexusPort = '8081'

$pp = Get-PackageParameters

if ($pp['Fqdn']) {
  $hostname = $pp['Fqdn']
}
  
if ($pp.Port) {
  $nexusPort = $pp.Port
  Write-Host "/Port was used, Nexus will listen on port $NexusPort."
}

If (Test-Path "$env:ProgramFiles\nexus\bin") {
  Throw "Previous version of Nexus 3 installed by setup.exe is present, please uninstall before running this package."
}

If ((Get-Service $serviceName -ErrorAction SilentlyContinue)) {
  Write-Warning "Nexus web app is already present, shutting it down so that we can upgrade it."
  Get-Service $serviceName | Stop-Service -Force
}

if ($pp['BackupSslConfig']) {
  if ($pp['BackupLocation']) {
    Backup-NexusSSL -BackupLocation $pp['BackupLocation']
  }

  else {
    Backup-NexusSSL
  }
}

If (Test-Path "$ExtractFolder") { 
  Remove-Item "$ExtractFolder" -Recurse -Force 
}

$packageArgs = @{
  PackageName    = $packageName
  unzipLocation  = $ExtractFolder
  url64          = $url64
  checksum64     = $checksum64
  checksumType64 = $checksumType64
}

Install-ChocolateyZipPackage @packageArgs

#$VerbosePreference = Continue
Write-Host "Copying files to '$TargetFolder' with overwrite"
If (Test-Path "$TargetFolder") { 
  Copy-Item "$ExtractFolder\$nexusversionedfolder\*" "$TargetFolder" -Force -Recurse
}
else {
  Copy-Item "$ExtractFolder\$nexusversionedfolder" "$TargetFolder" -Force -Recurse
}

If (!(Test-Path "$TargetDataFolder")) {
  Move-Item "$extractfolder\sonatype-work" "$TargetDataFolder"
}
else {
  Write-Warning "`"$TargetDataFolder`" already exists, not overwriting, residual data from previous installs will not be reset."
}

Remove-Item "$ExtractFolder" -Force -Recurse

$processArgs = @{
  ExeToRun       = "$TargetFolder\bin\nexus.exe"
  Statements     = "/install $servicename"
  validExitCodes = $validExitCodes
}

Start-ChocolateyProcessAsAdmin @processArgs

if ($pp['BackupSslConfig']) {
  if ($pp['BackupLocation']) {
    Restore-NexusSSL -BackupLocation $pp['BackupLocation']
  }

  else {
    Restore-NexusSSL
  }
}

#Update Port
If ($nexusPort -ne '8081') {
  If (Test-Path "$NexusConfigFile") {
    Write-Host "Configuring Nexus to listen on port $nexusPort."
    (Get-Content "$NexusConfigFile") -replace "^#\s*application-port=.*$", "application-port=$nexusPort" |
    Set-Content "$NexusConfigFile"
  }
  else {
    Write-Warning "Cannot find `"$NexusConfigFile`", skipping configuring Nexus to listen on port $nexusPort."
  }
}

$service = Start-Service $serviceName -PassThru

If ($Service.Status -ne 'Running') {
  Write-Warning "The Nexus Repository service ($serviceName) did not start."
}
else {
  #Even though windows reports service is ready - web url will not respond until Nexus is actually ready to serve content
  #We need to use this method to collect the port number so we can properly test the website has returned OK.
  $nexusScheme, $portConfigLine = if ($pp['BackupSSLConfig']) {
    # This is to combat Package Internalizer's over-enthusiastic URL matching
    ('http' + 's'), 'application-port-ssl'
  } else {
    'http', 'application-port'
  }

  # As the service is started, this should be present momentarily
  $Timer = [System.Diagnostics.Stopwatch]::StartNew()
  while (-not ($ConfigPresent = Test-Path $NexusConfigFile) -and $Timer.Elapsed.TotalSeconds -le 60) {
    Write-Verbose "Waiting for '$($NexusConfigFile)' to become available ($($Timer.Elapsed.TotalSeconds) seconds waited)..."
    Start-Sleep -Seconds 5
  }

  if (-not $ConfigPresent) {
    Write-Warning "Expected Nexus Config file '$($NexusConfigFile)' is not present."
    $nexusPath = '/'
  } else {
    $nexusPort = (Get-Content $NexusConfigFile | Where-Object {
      $_ -match $portConfigLine
    }).Split('=')[-1]

    $nexusPath = (Get-Content $NexusConfigFile | Where-Object {
      $_ -match "nexus-context-path"
    }).Split("=")[-1]
  }

  $nexusUri = "$($nexusScheme)://$($hostname):$($nexusPort)$($nexusPath)"

  Write-Host "Waiting on Nexus Web UI to be available at '$($nexusUri)'"
  while ($response.StatusCode -ne '200' -and $Timer.Elapsed.TotalMinutes -lt 3) {
    try {
      $response = Invoke-WebRequest -Uri $nexusUri -UseBasicParsing
    } catch {
      Write-Verbose "Waiting on Nexus Web UI to be available at '$($nexusUri)'"
      Start-Sleep -Seconds 1
    }
  }

  $Timer = $null

  if ($Response.StatusCode -eq '200') {
    Write-Host "Nexus is ready!"
  } else {
    Write-Error "Nexus did not respond to requests at '$($nexusUri)' within 3 minutes of the service being started."
  }
}
$generatedAdminPasswordFile = "$targetDataFolder\nexus3\admin.password"
$outputString = @"

*******************************************************************************************
*
*  You MAY receive the error 'localhost refused to connect.' until Nexus is fully started.
*
*  For new installs, you must login as admin to complete some setup steps
*  You can manage the repository by typing 'start http://$($hostname):$NexusPort'
*
*  The default user is 'admin'
*  ADMIN PASSWORD:
*    NEW INSTALLS: The password generated for your instance is recorded
*       in '$generatedAdminPasswordFile'
*    UPGRADES/REINSTALLS: If you upgraded (or uninstalled and reinstalled) without cleaning
*      up $targetDataFolder - the password will be the same as it was before and the password file
*      will not exist.
*    RESET PASSWORD WITH INSTALL: Uninstall Nexus and remove the directory '$targetDataFolder'
*      and then reinstall.  This time a password file will be generated.
*
*  Nexus availability is controlled via the service `"$servicename`"
*  Use the following command to open port $NexusPort for access from off this machine (one line):
*   netsh advfirewall firewall add rule name=`"Nexus Repository`" dir=in action=allow
*   protocol=TCP localport=$NexusPort
*******************************************************************************************
"@

Write-Warning $outputString
tools\chocolateyuninstall.ps1
$ErrorActionPreference = 'Stop'
$serviceName = 'nexus'
$installFolder = "$env:programdata\Nexus"
$validExitCodes = @(0)

if (Test-Path "$installfolder\bin\nexus.exe") {
  if (Get-Process $serviceName -ErrorAction SilentlyContinue) {
    Get-Process $serviceName | Stop-Process -Force
  }

  if (Get-Service $serviceName -ErrorAction SilentlyContinue){
    Stop-Service $serviceName
  }

  Start-Sleep -Seconds 5
  
  $processArgs = @{
    ExeToRun = "$installFolder\bin\nexus.exe"
    Statements = "/uninstall $servicename"
    validExitCodes = $validExitCodes
  }
  Start-ChocolateyProcessAsAdmin  @processArgs
  Remove-item  "$installfolder" -recurse -force
}
else {
  Write-warning "It appears that the uninstall may have been run outside of chocolatey, skipping..."
}
tools\supportingfunctions.psm1
Function Backup-NexusSSL {
  [CmdletBinding()]
  Param(
    [Parameter()]
    [String]
    $BackupLocation = $(Join-Path $env:UserProfile "NexusSSLBackup")
  )

  begin {

    if (-not (Test-Path $BackupLocation)) {
      Write-Host "Creating SSL Backup location"
      $null = New-Item $BackupLocation -ItemType Directory
    }

  }

  process {

    if (Test-Path "$env:ProgramData\nexus\etc\ssl\keystore.jks") {
      Copy-Item "$env:ProgramData\nexus\etc\ssl\keystore.jks" $BackupLocation
    }
    
    if (Test-Path "$env:ProgramData\nexus\etc\jetty\jetty-https.xml") {
      Copy-Item "$env:ProgramData\nexus\etc\jetty\jetty-https.xml" $BackupLocation
    }

  }


}

Function Restore-NexusSSL {
  [CmdletBinding()]
  Param(
    [Parameter()]
    [String]
    $BackupLocation = $(Join-Path $env:UserProfile "NexusSSLBackup")
  )

  process {
    Write-Host "Shutting down nexus Service to re-apply ssl configuration"
    $null = Stop-Service nexus

    Write-Host "Reapplying SSL Configuration"
    if (Test-Path "$BackupLocation\keystore.jks") {
      Copy-Item "$BackupLocation\keystore.jks" "$env:ProgramData\nexus\etc\ssl"
    }
    
    if (Test-Path "$BackupLocation\jetty-https.xml") {
      Copy-Item "$BackupLocation\jetty-https.xml" "$env:ProgramData\nexus\etc\jetty"
    }

  Write-Host "Nexus is now available with the restored SSL configuration"

  }
}

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Version Downloads Last Updated Status
Nexus Repository OSS 3.31.1.01 858 Wednesday, July 7, 2021 Approved
Nexus Repository OSS 3.31.0.01 198 Tuesday, June 22, 2021 Approved
Nexus Repository OSS 3.30.0.01 607 Thursday, April 29, 2021 Approved
Nexus Repository OSS 3.29.2.02 674 Wednesday, February 10, 2021 Approved
Nexus Repository OSS 3.29.1.01 298 Wednesday, January 6, 2021 Approved
Nexus Repository OSS 3.27.0.03 565 Friday, September 11, 2020 Approved
Nexus Repository OSS 3.25.1.02 318 Thursday, July 30, 2020 Approved
Nexus Repository OSS 3.22.1.02 585 Monday, April 20, 2020 Approved
Nexus Repository OSS 3.22.0.02 156 Saturday, April 11, 2020 Approved

Discussion for the Nexus Repository OSS Package

Ground Rules:

  • This discussion is only about Nexus Repository OSS and the Nexus Repository OSS package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Nexus Repository OSS, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus