Description of the issue
Hi,
I am leaning towards this being a fault at my end, more-so than a general bug in the product, but given my attempts to follow previous instructions from @BernieWhite as well as following the docs, I am curious if there is evidence that using powershell to run PSRule works with git diff in Azure DevOps?
It works when running locally.
I have set the following in ps-rule.yaml:
input:
ignoreUnchangedPath: true
repository:
baseRef: main
We use Azure DevOps with the following stage:
steps:
- checkout: self
fetchDepth: 0
- script: |
cd governance
git checkout ${$(Build.SourceBranch)#refs/heads/}
displayName: Prepare git
- checkout: common
- task: PowerShell@2
name: PSRule_pre_deployment
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/governance/tests/PSRulePreDeployment.ps1
pwsh: true
errorActionPreference: stop
failOnStderr: true
continueOnError: false
- "governance" being our repo name in the above that we want to test
- "common" is a library repo, which contains custom ps rules such as naming convention
- PSRulePreDeployment.ps1 contains some logic to ensure PSRule modules and deps are installed from PSGallery, sets the directory for where to run, and runs Assert-PSRule with -InputPath as the root of the repo to test, -Option points to the ps-rule.yml where the above code snippet is taken from, and -Path points to the folder containing the custom rules in the "common" repo.
I have also tried setting the "PSRULE_INPUT_IGNOREUNCHANGEDPATH" env var in the PowerShell@2 task, it did not affect the outcome.
I use the cd and git checkout commands to overcome the detached head, which I get despite having fetchDepth set to 0, and the PSRule docs states detached heads are not supported
My questions:
- Could it be confirmed that "ignore unchanged path" works for how Azure DevOps handles repos?
- If it works in your end, can you spot what I am doingwrong?
- If it does not work; perhaps using git rev-parse internally in PSRule would be an option to overcome this, as method to getting changes between branches, which works in detached head?
Error messages
N/A - but all files are being scanned.
Reproduction
Described under "description of issue"
Version of PSRule
2.9.0
How are you running PSRule
Azure DevOps triggering a PowerShell task
Additional context
No response
Description of the issue
Hi,
I am leaning towards this being a fault at my end, more-so than a general bug in the product, but given my attempts to follow previous instructions from @BernieWhite as well as following the docs, I am curious if there is evidence that using powershell to run PSRule works with git diff in Azure DevOps?
It works when running locally.
I have set the following in ps-rule.yaml:
We use Azure DevOps with the following stage:
I have also tried setting the "PSRULE_INPUT_IGNOREUNCHANGEDPATH" env var in the PowerShell@2 task, it did not affect the outcome.
I use the cd and git checkout commands to overcome the detached head, which I get despite having fetchDepth set to 0, and the PSRule docs states detached heads are not supported
My questions:
Error messages
N/A - but all files are being scanned.
Reproduction
Described under "description of issue"
Version of PSRule
2.9.0
How are you running PSRule
Azure DevOps triggering a PowerShell task
Additional context
No response