0
1
Hello I am trying to run a powershell script as a build step using MSBuild on jenkins. The script runs fine on local builds, all it does it modify the version number and them saves the file. Set-Content is what is failing.
15:26:28 Set-Content : Access to the path 'D:\Workspaces\SOURCE\ApplicationLabel.h' is denied.
15:26:28 At D:\Workspaces\SOURCE\updateVersion.ps1:64 char:1
15:26:28 + Set-Content -Path ./ApplicationLabel.h -Value $appLabel
15:26:28 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15:26:28 + CategoryInfo : NotSpecified: (:) [Set-Content], UnauthorizedAccessException
15:26:28 + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetContentCommand
I assumed this was because Jenkins didn't have permission to write. But It is running as a service and still fails.
The script is called in the config as such:
powershell.exe -NonInteractive -ExecutionPolicy ByPass "& './updateVersion.ps1'
Here is a snippet from the file:
$changeset =Get-LatestChangeset;
$versionString = "#define BuildVersion L`"$versionNum.$changeset`""
$appLabel = Get-Content -Path ./ApplicationLabel.h
$appLabel = $appLabel -replace '#define BuildVersion L.*"',$versionString
$appLabel = $appLabel -replace '#define BuildDate L.*',$date
Set-Content -Path ./ApplicationLabel.h -Value $appLabel
Is there are readonly setting for workspace source files?