Skip to content

Commit

Permalink
Added Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
paulkronabethleitner committed Nov 5, 2024
1 parent 6ce0d19 commit d9f80d0
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions example-scripts/powershell/runLTAonLinux.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,45 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

#this scripts downloads and prepares Lemontree.Automation on a Linux machine.
#This scripts downloads and prepares Lemontree.Automation on a Linux machine.

$LemonTreePackageURL = "https://nexus.lieberlieber.com/repository/lemontree-release/LemonTree.Automation/LemonTree.Automation.Linux.Zip_latest.zip"
$LemonTreeZip = "LTA.zip"
$DestinationPath = "./LTA/"
$LemonTreeExe = "./LTA/lemontree.automation"

Write-Output "Download LemonTree.Automtion from Repo"
Invoke-WebRequest -URI "$LemonTreePackageURL" -OutFile "LTA.zip"
Expand-Archive "LTA.zip" -DestinationPath ".\LTA\" -Force
Write-Output "Downloading LemonTree.Automation from Nexus..."

$LemonTreeExe = "./LTA/lemontree.automation"
#workaround because github artifacts logic doesn't maintain properties
chmod +x $LemonTreeExe
try {
# Attempt to download the file
Invoke-WebRequest -URI $LemonTreePackageURL -OutFile $LemonTreeZip -ErrorAction Stop
Write-Output "Download successful."
} catch {
Write-Output "Error: Failed to download LemonTree.Automation. $_"
exit 1
}

Write-Output "LemonTreeAutomationExecutable=$LemonTreeExe"
Write-Output "Extracting $LemonTreeZip..."

try {
# Attempt to extract the archive
Expand-Archive -Path $LemonTreeZip -DestinationPath $DestinationPath -Force -ErrorAction Stop
Write-Output "Extraction successful."
} catch {
Write-Output "Error: Failed to extract $LemonTreeZip. $_"
exit 1
}

Write-Output "Setting executable permissions for $LemonTreeExe..."

try {
# Attempt to set executable permissions
chmod +x $LemonTreeExe
Write-Output "Permissions set successfully."
} catch {
Write-Output "Error: Failed to set executable permissions for $LemonTreeExe. $_"
exit 1
}

Write-Output "LemonTreeAutomationExecutable=$LemonTreeExe"
exit 0

0 comments on commit d9f80d0

Please sign in to comment.