QuestionQ56

DevSecOps 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?

  • A If the code exits with 3, then the commit is successful
  • B If the code exits with 0, then the commit is successful
  • C If the code exits with 2, then the commit is successful
  • D If the code exits with 1, then the commit is 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!