mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 17:51:28 +01:00
Added cd-jenkins.ps1
This commit is contained in:
parent
d01b5969eb
commit
b2413adad6
29
scripts/cd-jenkins.ps1
Executable file
29
scripts/cd-jenkins.ps1
Executable file
@ -0,0 +1,29 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Changes to the Jenkins home directory
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the Jenkins home directory.
|
||||
.EXAMPLE
|
||||
PS> ./cd-jenkins
|
||||
📂C:\Users\Markus\.jenkins
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
if (Test-Path "~/.jenkins" -pathType container) {
|
||||
$path = "~/.jenkins"
|
||||
} elseif (Test-Path "/var/snap/jenkins" -pathType container) {
|
||||
$path = "/var/snap/jenkins"
|
||||
} else {
|
||||
throw "The Jenkins home directory doesn't exist (yet)"
|
||||
}
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user