33 lines
953 B
PowerShell
33 lines
953 B
PowerShell
# 사용자에게 새 워크스페이스 경로 입력 받기
|
|
$newWorkspaceDir = Read-Host "Enter the new workspace directory"
|
|
|
|
# Jenkins 설정 파일 경로
|
|
$configPath = "C:\ProgramData\Jenkins\.jenkins\config.xml"
|
|
|
|
# 백업 파일 만들기
|
|
Copy-Item $configPath "$configPath.bak"
|
|
|
|
# 기존 XML 읽기
|
|
[xml]$configXml = Get-Content $configPath
|
|
|
|
# workspaceDir 요소가 존재하는 경우 수정, 없으면 새로 추가
|
|
if ($configXml.jenkins.workspaceDir) {
|
|
$configXml.jenkins.workspaceDir = $newWorkspaceDir
|
|
} else {
|
|
$workspaceNode = $configXml.CreateElement("workspaceDir")
|
|
$workspaceNode.InnerText = $newWorkspaceDir
|
|
$configXml.jenkins.AppendChild($workspaceNode) | Out-Null
|
|
}
|
|
|
|
# 수정된 내용 저장
|
|
$configXml.Save($configPath)
|
|
|
|
Write-Host "Workspace directory successfully updated."
|
|
|
|
# Jenkins 재시작
|
|
Write-Host "Restarting Jenkins service..."
|
|
Restart-Service jenkins -Force
|
|
|
|
Write-Host "Jenkins has been restarted."
|
|
|