[Jenkins] GIT Parameter fatal: Couldn’t find remote refs/heads/${BRANCH_ON_GIT}

หลังจากย้ายจาก SVN ไป GIT มันมีการแก้ Script ของ Automate Build ด้วยครับ มาดูพฤติกรรมของ Job Build กันก่อนไหมครับ

  • Job A : GIT_CONTROLLER_PIPELINE - โดยมีเรียก 1 Job ซ้ำกัน 3 ครั้ง ดังนี้
    • Job B: SOLUTION_GIT_PIPELINE - ส่ง Param สำหรับ SITE A
    • Job B: SOLUTION_GIT_PIPELINE - ส่ง Param สำหรับ SITE B
    • Job B: SOLUTION_GIT_PIPELINE - ส่ง Param สำหรับ SITE C

ปัญหา : มันเกิดขึ้นจากที่ Job A เรียก Job B ทำงานต่อ ตอนที่ส่ง Param ผ่าน Git Parameter มันเเกิด Error ดังนี้ครับ

Started by user admin
hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress --prune -- origin +refs/heads/${BRANCH_ON_GIT}:refs/remotes/origin/${BRANCH_ON_GIT}" returned status code 128:
stdout: 
stderr: fatal: Couldn't find remote ref refs/heads/${BRANCH_ON_GIT}
   at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
   at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
   at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
   at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
   at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
   at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
   at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
   at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115)
   at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69)
   at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
   at hudson.model.ResourceController.execute(ResourceController.java:97)
   at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

การแก้ไข : ง่ายนิดเดียวเองครับ ใน Job Build ให้ติ๊กเลือก Lightweight checkout ออกครับ