QuestionQ56

VerifiedDevSecOps Pipeline-Code Stage

Jordon Garrett works as a DevSecOps engineer at an IT company located in Chicago, Illinois. His team prefers PowerShell for using Git hooks because Bash and Windows are incompatible for advanced executions. To call a PowerShell script from a Bash shell, Jordon created a PowerShell script with pre-commit logic, such as pre-commit.ps1, and executed the following commands:

#!C:/Program\Files/Git/usr/bin/sh.exe  
exec powershell.exe -NoProfile -ExecutionPolicy Bypass -File “.\.git\hooks\pre-commit.ps1”  

How would Jordon determine that the commit was successful?

Explanation

A Git pre-commit hook allows the commit to continue when it exits with status 0. Any nonzero exit status signals hook failure and causes Git to abort the commit before creating it.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!