Finally I implemented it myself.
Since AWX 4, the awx_project_scm_branch
and awx_job_scm_branch
variables are available in playbooks environments.
The related documentation can be found in https://docs.ansible.com/automation-controller/4.4/html/userguide/job_templates.html