1.9 KiB
Generated 2026-05-12 at base-sha 28f54cf7bef9. Type: concept. 0 sources.
SCM Variable Scope
The scm variable is only available inside consumer Jenkinsfiles, not inside vars/ or src/ of the shared library. Referencing it in library code causes a runtime MissingPropertyException.
Where it applies in this repo
vars/eksCICD.groovy and all files under src/com/meesho/
Why scm is unavailable
The scm variable (branch, remote URL, credentials) is injected by the GitHub Branch Source plugin into consumer Jenkinsfiles at the time they are loaded by Jenkins. Library code (everything under vars/ and src/) is a separate classloader context — the plugin does not inject scm there.
Attempting to access scm.branches or scm.userRemoteConfigs from library code will throw:
MissingPropertyException: No such property: scm for class: groovy.lang.Binding
Correct alternatives
Inside library code, use the Jenkins-injected environment variables instead:
| Need | Use instead of scm.* |
|---|---|
| Branch name | env.BRANCH_NAME |
| Repository URL | env.GIT_URL |
| PR number | env.CHANGE_ID |
| PR source branch | env.CHANGE_BRANCH |
| PR target branch | env.CHANGE_TARGET |
All of these are set by the GitHub Branch Source plugin before library code runs.
Related
- Entry points — where this constraint applies
- Environment mapping —
env.CHANGE_IDis the PR-build detector
Sources
(no raw/ sources)