Created
August 7, 2020 02:38
-
-
Save adilio/c16004013e13dd841819d47c5d4e9f13 to your computer and use it in GitHub Desktop.
The latest Nexus version, 3.25.1*, does not upgrade smoothly. New exe version is not pointed to, and SSL certs are not preserved. This script is a workaround for that, with Chocolatey running the upgrade piece.
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
Stop-Service nexus | |
#Backup SSL Configuration | |
if(-not (Test-Path C:\nexusbackup)){ | |
New-Item C:\nexusbackup -ItemType Directory | |
} | |
if(Test-Path C:\ProgramData\nexus\etc\ssl\keystore.jks){ | |
Copy-Item C:\ProgramData\nexus\etc\ssl\keystore.jks C:\nexusbackup | |
} | |
if(Test-Path C:\ProgramData\nexus\etc\jetty\jetty-https.xml){ | |
Copy-Item C:\ProgramData\nexus\etc\jetty\jetty-https.xml C:\nexusbackup | |
} | |
#Remove the current Nexus folder | |
Remove-Item C:\ProgramData\nexus -Recurse -Force -ErrorAction SilentlyContinue | |
#Upgrade the package | |
choco upgrade nexus-repository -y -f -s "'https://chocolatey.org/api/v2/'" | |
#Restore SSL Configuration | |
if(Test-Path C:\nexusbackup\keystore.jks){ | |
Copy-Item C:\nexusbackup\keystore.jks C:\ProgramData\nexus\etc\ssl | |
} | |
if(Test-Path C:\nexusbackup\jetty-https.xml){ | |
Copy-Item C:\nexusbackup\jetty-https.xml C:\ProgramData\nexus\etc\jetty | |
} | |
#Restart the nexus service to apply the configuration | |
Start-Service nexus | |
#Cleanup backup folder | |
Remove-Item C:\nexusbackup -Recurse -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment