Which command configures a post-commit build hook to run a script ("curl http://api.com/user/${USER}") for a BuildConfig named "name"?

Prepare for the Red Hat OpenShift Developer II DO288 Exam with our quizzes. Study with flashcards and multiple choice questions, each with hints and explanations. Get ready for your certification!

Multiple Choice

Which command configures a post-commit build hook to run a script ("curl http://api.com/user/${USER}") for a BuildConfig named "name"?

Explanation:
Setting up a post-commit hook to run a script in OpenShift is done by attaching a script to the BuildConfig’s post-commit hook using oc set build-hook, targeting the BuildConfig by bc/name and providing the script as a single string. The correct form uses the post-commit flag and the script option, with the curl command placed inside quotes so it’s executed as one script piece after the commit finishes. The ${USER} variable will be expanded by the shell when the script runs, sending the appropriate user value to the API. So, using --post-commit with --script="curl http://api.com/user/${USER}" is the proper syntax, and it ensures the hook fires after the commit and runs exactly that command. The other approaches either target a different hook (pre-commit), or misuse the command format (such as not quoting the script or using an option form that isn’t intended for a script), which would not achieve the required post-commit behavior.

Setting up a post-commit hook to run a script in OpenShift is done by attaching a script to the BuildConfig’s post-commit hook using oc set build-hook, targeting the BuildConfig by bc/name and providing the script as a single string. The correct form uses the post-commit flag and the script option, with the curl command placed inside quotes so it’s executed as one script piece after the commit finishes. The ${USER} variable will be expanded by the shell when the script runs, sending the appropriate user value to the API.

So, using --post-commit with --script="curl http://api.com/user/${USER}" is the proper syntax, and it ensures the hook fires after the commit and runs exactly that command. The other approaches either target a different hook (pre-commit), or misuse the command format (such as not quoting the script or using an option form that isn’t intended for a script), which would not achieve the required post-commit behavior.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy