/* Ċ Ġ* ĠTencent Ġis Ġplease d Ġto Ġsupport Ġthe Ġopen Ġsource Ġcommunity Ġby Ġmaking ĠB K - CI Ġ èĵĿ é² ¸ æĮģ ç»Ń éĽĨ æĪĲ å¹³åı° Ġavailable . Ċ Ġ* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 9 ĠTH L ĠA 2 9 ĠLimited , Ġa ĠTencent Ġcompany . Ġ ĠAll Ġrights Ġreserved . Ċ Ġ* Ċ Ġ* ĠB K - CI Ġ èĵĿ é² ¸ æĮģ ç»Ń éĽĨ æĪĲ å¹³åı° Ġis Ġlicensed Ġunder Ġthe ĠMIT Ġlicense . Ċ Ġ* Ċ Ġ* ĠA Ġcopy Ġof Ġthe ĠMIT ĠLicense Ġis Ġincluded Ġin Ġthis Ġfile . Ċ Ġ* Ċ Ġ* Ċ Ġ* ĠTerms Ġof Ġthe ĠMIT ĠLicense : Ċ Ġ* Ġ------------------------------------------------ --- Ċ Ġ* ĠPermission Ġis Ġhereby Ġgranted , Ġfree Ġof Ġcharge , Ġto Ġany Ġperson Ġobtaining Ġa Ġcopy Ġof Ġthis Ġsoftware Ġand Ġassociated Ġdocumentation Ċ Ġ* Ġfiles Ġ( the Ġ" Software "), Ġto Ġdeal Ġin Ġthe ĠSoftware Ġwithout Ġrestriction , Ġincluding Ġwithout Ġlimitation Ġthe Ġrights Ġto Ġuse , Ġcopy , Ċ Ġ* Ġmodify , Ġmerge , Ġpublish , Ġdistribute , Ġsublicense , Ġand / or Ġsell Ġcopies Ġof Ġthe ĠSoftware , Ġand Ġto Ġpermit Ġpersons Ġto Ġwhom Ġthe Ċ Ġ* ĠSoftware Ġis Ġfurnished Ġto Ġdo Ġso , Ġsubject Ġto Ġthe Ġfollowing Ġconditions : Ċ Ġ* Ċ Ġ* ĠThe Ġabove Ġcopyright Ġnotice Ġand Ġthis Ġpermission Ġnotice Ġshall Ġbe Ġincluded Ġin Ġall Ġcopies Ġor Ġsubstantial Ġportions Ġof Ġthe ĠSoftware . Ċ Ġ* Ċ Ġ* ĠTHE ĠSOFTWARE ĠIS ĠPROVIDED Ġ" AS ĠIS ", ĠWITHOUT ĠWARRANTY ĠOF ĠANY ĠKIND , ĠEXPRESS ĠOR ĠIMPLIED , ĠINCLUDING ĠBUT ĠNOT Ċ Ġ* ĠLIMITED ĠTO ĠTHE ĠWARRANTIES ĠOF ĠMERCHANTABILITY , ĠFITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE ĠAND ĠNONINFRINGEMENT . ĠIN Ċ Ġ* ĠNO ĠEVENT ĠSHALL ĠTHE ĠAUTHORS ĠOR ĠCOPYRIGHT ĠHOLDERS ĠBE ĠLIABLE ĠFOR ĠANY ĠCLAIM , ĠDAMAGES ĠOR ĠOTHER ĠLIABILITY , Ċ Ġ* ĠWHETHER ĠIN ĠAN ĠACTION ĠOF ĠCONTRACT , ĠTORT ĠOR ĠOTHERWISE , ĠARISING ĠFROM , ĠOUT ĠOF ĠOR ĠIN ĠCONNECTION ĠWITH ĠTHE Ċ Ġ* ĠSOFTWARE ĠOR ĠTHE ĠUSE ĠOR ĠOTHER ĠDEALINGS ĠIN ĠTHE ĠSOFTWARE . Ċ Ġ*/ Ċ Ċ package Ġcom . tencent . devops . process . utils Ċ Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertNot Equals Ċ import Ġorg . junit . Test Ċ Ċ class ĠPipeline Var Util Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfill Old Var () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġvars Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPI PE LINE _ START _ USER _ NAME Ġto Ġ" admin ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" userName " Ġto Ġ" hello ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ PIPELINE _ MAT ERIAL _ URL . rep / a 1 " Ġto Ġ" http :// git . xxx . com / group / repo . git " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠPipeline Var Util . fill Old Var ( vars ) ĊĠĠĠĠĠĠĠ Ġvars . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreplace Old By New Var () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġvars Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" pipeline . start . user . name " Ġto Ġ" admin ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" userName " Ġto Ġ" hello ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" pipeline . material . url . rep / a 1 " Ġto Ġ" http :// git . xxx . com / group / repo . git " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠPipeline Var Util . replace Old By New Var ( vars ) ĊĠĠĠĠĠĠĠ Ġvars . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmix Old Var And New Var () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġvars Ġ= Ġmutable Map Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" repo Name " Ġto Ġ" hello / world ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPI PE LINE _ REPO _ NAME Ġto Ġ" tencent / bk - ci " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġassert Not Equals ( vars [ PIPELINE _ REPO _ NAME ], Ġvars [" repo Name "]) ĊĠĠĠĠĠĠĠ Ġval Ġmix Old Var And New Var Ġ= ĠPipeline Var Util . mix Old Var And New Var ( vars ) ĊĠĠĠĠĠĠĠ Ġprintln ( mix Old Var And New Var ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( vars [ PIPELINE _ REPO _ NAME ], Ġ" tencent / bk - ci ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( vars [ PIPELINE _ REPO _ NAME ], Ġmix Old Var And New Var [" repo Name "]) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġold Var To New Var () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( MAJOR VERSION , ĠPipeline Var Util . old Var To New Var (" Major Version ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( MINOR VERSION , ĠPipeline Var Util . old Var To New Var (" Minor Version ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( FIX VERSION , ĠPipeline Var Util . old Var To New Var (" Fix Version ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( BUILD _ NO , ĠPipeline Var Util . old Var To New Var (" Build No ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ START _ CHANNEL , ĠPipeline Var Util . old Var To New Var (" pipeline . start . channel ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ BUILD _ LAST _ UPDATE , ĠPipeline Var Util . old Var To New Var (" pipeline . build . last . update ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ BUILD _ SV N _ REVISION , ĠPipeline Var Util . old Var To New Var (" pipeline . build . svn . revision ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPI PE LINE _ START _ PARENT _ PIPELINE _ ID , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPipeline Var Util . old Var To New Var (" pipeline . start . parent . pipeline . id ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ START _ USER _ ID , ĠPipeline Var Util . old Var To New Var (" pipeline . start . user . id ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ START _ TASK _ ID , ĠPipeline Var Util . old Var To New Var (" pipeline . start . task . id ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ START _ USER _ NAME , ĠPipeline Var Util . old Var To New Var (" pipeline . start . user . name ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ START _ TYPE , ĠPipeline Var Util . old Var To New Var (" pipeline . start . type ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ BUILD _ NUM , ĠPipeline Var Util . old Var To New Var (" pipeline . build . num ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ WEB HOOK _ REVISION , ĠPipeline Var Util . old Var To New Var (" hook Revision ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ WEB HOOK _ BRANCH , ĠPipeline Var Util . old Var To New Var (" hook Branch ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ WEB HOOK _ SOURCE _ BRANCH , ĠPipeline Var Util . old Var To New Var (" hook Source Branch ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ WEB HOOK _ TARGET _ BRANCH , ĠPipeline Var Util . old Var To New Var (" hook Target Branch ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( GIT _ MR _ NUMBER , ĠPipeline Var Util . old Var To New Var (" git _ mr _ number ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( GITHUB _ PR _ NUMBER , ĠPipeline Var Util . old Var To New Var (" github _ pr _ number ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PROJECT _ NAME , ĠPipeline Var Util . old Var To New Var (" project . name ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ BUILD _ ID , ĠPipeline Var Util . old Var To New Var (" pipeline . build . id ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ VM SEQ _ ID , ĠPipeline Var Util . old Var To New Var (" pipeline . job . id ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ ELEMENT _ ID , ĠPipeline Var Util . old Var To New Var (" pipeline . task . id ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ TUR BO _ TASK _ ID , ĠPipeline Var Util . old Var To New Var (" tur bo . task . id ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( REPORT _ DYNAMIC _ ROOT _ URL , ĠPipeline Var Util . old Var To New Var (" report . dynamic . root . url ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ TIME _ DURATION , ĠPipeline Var Util . old Var To New Var (" pipeline . time . duration ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PROJECT _ NAME _ CH INE SE , ĠPipeline Var Util . old Var To New Var (" project . name . chinese ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PIPELINE _ NAME , ĠPipeline Var Util . old Var To New Var (" pipeline . name ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnew Var To Old Var () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals (" Major Version ", ĠPipeline Var Util . new Var To Old Var ( MAJOR VERSION )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Minor Version ", ĠPipeline Var Util . new Var To Old Var ( MINOR VERSION )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Fix Version ", ĠPipeline Var Util . new Var To Old Var ( FIX VERSION )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Build No ", ĠPipeline Var Util . new Var To Old Var ( BUILD _ NO )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . start . channel ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ START _ CHANNEL )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . build . last . update ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ BUILD _ LAST _ UPDATE )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . build . svn . revision ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ BUILD _ SV N _ REVISION )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" pipeline . start . parent . pipeline . id ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ START _ PARENT _ PIPELINE _ ID ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . start . user . id ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ START _ USER _ ID )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . start . task . id ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ START _ TASK _ ID )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . start . user . name ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ START _ USER _ NAME )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . start . type ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ START _ TYPE )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . build . num ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ BUILD _ NUM )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" hook Revision ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ WEB HOOK _ REVISION )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" hook Branch ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ WEB HOOK _ BRANCH )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" hook Source Branch ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ WEB HOOK _ SOURCE _ BRANCH )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" hook Target Branch ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ WEB HOOK _ TARGET _ BRANCH )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" git _ mr _ number ", ĠPipeline Var Util . new Var To Old Var ( GIT _ MR _ NUMBER )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" github _ pr _ number ", ĠPipeline Var Util . new Var To Old Var ( GITHUB _ PR _ NUMBER )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" project . name ", ĠPipeline Var Util . new Var To Old Var ( PROJECT _ NAME )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . build . id ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ BUILD _ ID )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . job . id ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ VM SEQ _ ID )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . task . id ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ ELEMENT _ ID )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" tur bo . task . id ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ TUR BO _ TASK _ ID )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" report . dynamic . root . url ", ĠPipeline Var Util . new Var To Old Var ( REPORT _ DYNAMIC _ ROOT _ URL )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . time . duration ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ TIME _ DURATION )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" project . name . chinese ", ĠPipeline Var Util . new Var To Old Var ( PROJECT _ NAME _ CH INE SE )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" pipeline . name ", ĠPipeline Var Util . new Var To Old Var ( PIPELINE _ NAME )) ĊĠĠĠ Ġ} Ċ }