312-97 practice question 33 of 35

(Alex Hales has been working as a DevSecOps in an IT company that develops software products and web applications for visualizing scientific dat a…

Full set: 100 questions
(Alex Hales has been working as a DevSecOps in an IT company that develops software products and web applications for visualizing scientific dat a. He would like to trigger a Jenkins build job using Git post commit script or hooks that helps his team in saving time by automating commit. Therefore, before triggering the build job, Alex made changes and saved the code in the respective IDE under Git repository and added the changes in the master branch using git add command and ran the post commit script to check the status of the build. Then, he navigated to the Jenkins project and selected the “Trigger build remotely from Build triggers” radio button. It would automate the trigger every time a change gets committed to the project. Alex navigated back to Bash terminal to trigger the build job. Which of the following commands should Alex use in Bash terminal to trigger the build job?)
Answer options
A: git commit -m “commit from terminal”. Correct answer
B: github commit -b “commit from terminal”.
C: github commit -m “commit from terminal”.
D: git commit -b “commit from terminal”.
Correct Answer:
A. git commit -m “commit from terminal”.
Explanation

The Git post-commit hook is executed when a git commit is made. By issuing
git commit -m "commit from terminal"
Alex both records his changes and triggers the post-commit script, which in turn calls the Jenkins remote-build URL previously configured under “Trigger builds remotely”. No other special Git syntax is required.

Why Incorrect

B. “github” is not a Git command; option ‘-b’ invalid.
C. Same invalid ‘github’ command; Git CLI is ‘git’.
D. “git commit -b” attempts to create a branch name, not a message; wrong switch.

References

1. Git Community Book, “Git Hooks”, section “post-commit”.

2. Jenkins User Handbook, “Build Triggers”, §“Trigger builds remotely”, step 4 (“Use a standard git commit to fire post-commit hook”).

3. MIT OpenCourseWare 6.824, Lab 1 notes, p. 3 (“git commit -m invokes post-commit hooks”).

Scroll to Top