[{"data":1,"prerenderedAt":510,"buildId":511},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Fintegrations\u002Fci":3},{"id":4,"title":5,"body":6,"description":493,"extension":494,"frontmatter":495,"heading":5,"meta":501,"navigation":503,"order":486,"path":504,"seo":505,"sitemap":506,"source":507,"stem":508,"__hash__":509},"docs\u002Fdocs\u002F5.x\u002Fintegrations\u002Fci.md","Publish Kubb Studio snapshots from CI",{"type":7,"value":8,"toc":481},"minimark",[9,24,27,37,41,46,87,145,153,157,248,253,262,327,344,348,362,365,370,374,382,418,458,461],[10,11,12,13,17,18,23],"p",{},"A snapshot is an installable npm package of your generated code. ",[14,15,16],"code",{},"kubb studio snapshot"," builds it on the CI runner, uploads it to ",[19,20,22],"a",{"href":21},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fstudio","Studio",", and exits.",[10,25,26],{},"Run it on pull or merge requests and on their base branch, so each request has a snapshot to compare with.",[10,28,29,30,36],{},"A snapshot shows what a request changes in the generated code. To fail a pipeline when the committed code is out of date, use ",[19,31,33],{"href":32},"\u002Fdocs\u002F5.x\u002Fhow-to\u002Frecipes#check-generated-code-in-ci",[14,34,35],{},"kubb generate --check",".",[38,39],"mermaid",{"svg":40},"\u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" class=\"pele pele-flowchart\" viewBox=\"0 0 903 152\" width=\"903\" height=\"152\" style=\"--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,monospace);font:16px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,sans-serif)\" fill=\"var(--_fg)\" role=\"graphics-document document\" aria-roledescription=\"flowchart\">\u003Cg class=\"pele-edges\" fill=\"none\" stroke=\"var(--_l)\" stroke-linecap=\"round\">\u003Cg class=\"pele-edge\" data-id=\"L_pr_job_0\">\u003Cpath d=\"M128.48,76L169.48,76\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M176.48,76L168.48,79.36L168.48,72.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge\" data-id=\"L_job_snap_0\">\u003Cpath d=\"M254.27,76L295.27,76\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M302.27,76L294.27,79.36L294.27,72.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge\" data-id=\"L_snap_studio_0\">\u003Cpath d=\"M489.47,76L595.39,76\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M602.39,76L594.39,79.36L594.39,72.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge\" data-id=\"L_studio_review_0\">\u003Cpath d=\"M725.56,68C743.06,68 743.06,32 760.56,32L766.56,32\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M773.56,32L765.56,35.36L765.56,28.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003Cg class=\"pele-edge\" data-id=\"L_studio_install_0\">\u003Cpath d=\"M725.56,84C743.06,84 743.06,120 760.56,120L766.56,120\"\u002F>\u003Cpath class=\"pele-marker\" d=\"M773.56,120L765.56,123.36L765.56,116.64Z\" fill=\"var(--_l)\" stroke=\"none\"\u002F>\u003C\u002Fg>\u003C\u002Fg>\u003Cg class=\"pele-edge-labels\" font-size=\"14\">\u003Cg class=\"pele-edge-label\" data-id=\"L_snap_studio_0\">\u003Crect x=\"511.97\" y=\"65.5\" width=\"60.92\" height=\"21\" rx=\"3\" fill=\"var(--_bg)\"\u002F>\u003Ctext x=\"542.43\" y=\"80.9\" text-anchor=\"middle\">package\u003C\u002Ftext>\u003C\u002Fg>\u003C\u002Fg>\u003Cg class=\"pele-nodes\">\u003Cg class=\"pele-node pele-shape-rect\" data-id=\"pr\" transform=\"translate(68.24,76)\">\u003Crect x=\"-60.24\" y=\"-24\" width=\"120.48\" height=\"48\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"5.6\" text-anchor=\"middle\">Pull request\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-shape-rect\" data-id=\"job\" transform=\"translate(215.38,76)\">\u003Crect x=\"-38.9\" y=\"-24\" width=\"77.79\" height=\"48\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"5.6\" text-anchor=\"middle\">CI job\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-shape-rect core\" data-id=\"snap\" transform=\"translate(395.87,76)\">\u003Crect x=\"-93.6\" y=\"-24\" width=\"187.2\" height=\"48\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"5.6\" text-anchor=\"middle\">kubb studio snapshot\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-shape-rect\" data-id=\"studio\" transform=\"translate(663.98,76)\">\u003Crect x=\"-61.58\" y=\"-24\" width=\"123.17\" height=\"48\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"5.6\" text-anchor=\"middle\">Kubb Studio\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-shape-rect\" data-id=\"review\" transform=\"translate(834.23,32)\">\u003Crect x=\"-60.67\" y=\"-24\" width=\"121.34\" height=\"48\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"5.6\" text-anchor=\"middle\">Review files\u003C\u002Ftext>\u003C\u002Fg>\u003Cg class=\"pele-node pele-shape-rect\" data-id=\"install\" transform=\"translate(829.79,120)\">\u003Crect x=\"-56.23\" y=\"-24\" width=\"112.46\" height=\"48\" fill=\"var(--_s)\" stroke=\"var(--_b)\" style=\"rx:var(--_r)\"\u002F>\u003Ctext class=\"pele-label\" x=\"0\" y=\"5.6\" text-anchor=\"middle\">npm install\u003C\u002Ftext>\u003C\u002Fg>\u003C\u002Fg>\u003C\u002Fsvg>",[42,43,45],"h2",{"id":44},"prerequisites","Prerequisites",[47,48,49,61,79],"ul",{},[50,51,52,53,56,57,36],"li",{},"A working ",[14,54,55],{},"kubb.config.ts"," on Kubb 5.6.2 or later. See ",[19,58,60],{"href":59},"\u002Fdocs\u002F5.x\u002Fintroduction\u002Finstallation","Installation",[50,62,63,66,67,70,71,74,75,78],{},[14,64,65],{},"tsdown"," next to ",[14,68,69],{},"kubb"," in the dev dependencies (",[14,72,73],{},"npm i -D tsdown","). Snapshots build their ",[14,76,77],{},"dist"," files with it.",[50,80,81,82,86],{},"Two Studio API keys, created under ",[83,84,85],"strong",{},"Settings › Developers › Tokens",":",[88,89,90,106],"table",{},[91,92,93],"thead",{},[94,95,96,100,103],"tr",{},[97,98,99],"th",{},"Key type",[97,101,102],{},"Store it as",[97,104,105],{},"Used for",[107,108,109,124],"tbody",{},[94,110,111,115,121],{},[112,113,114],"td",{},"CI",[112,116,117,120],{},[14,118,119],{},"KUBB_TOKEN",", in a secret only trusted pipelines can read",[112,122,123],{},"Publishing snapshots",[94,125,126,129,139],{},[112,127,128],{},"Registry",[112,130,131,134,135,138],{},[14,132,133],{},"KUBB_REGISTRY_TOKEN",", which ",[14,136,137],{},".npmrc"," reads",[112,140,141],{},[19,142,144],{"href":143},"#install-the-snapshot","Installing a snapshot",[10,146,147,148,152],{},"When the config exports an ",[19,149,151],{"href":150},"\u002Fdocs\u002F5.x\u002Freference\u002Fconfiguration#multiple-configurations-array","array",", the snapshot packs every entry's output into one package.",[42,154,156],{"id":155},"supported-providers","Supported providers",[88,158,159,175],{},[91,160,161],{},[94,162,163,166,169,172],{},[97,164,165],{},"Provider",[97,167,168],{},"Agent identity",[97,170,171],{},"Compares with the base branch",[97,173,174],{},"Setup",[107,176,177,192,206,228],{},[94,178,179,182,185,187],{},[112,180,181],{},"GitHub Actions",[112,183,184],{},"Detected",[112,186,184],{},[112,188,189],{},[19,190,181],{"href":191},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fgithub-actions",[94,193,194,197,199,201],{},[112,195,196],{},"GitLab CI",[112,198,184],{},[112,200,184],{},[112,202,203],{},[19,204,196],{"href":205},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fgitlab",[94,207,208,211,213,219],{},[112,209,210],{},"Bitbucket Pipelines, CircleCI",[112,212,184],{},[112,214,215,216],{},"Pass ",[14,217,218],{},"--base-id",[112,220,221,222,224,225,227],{},"Run ",[14,223,16],{}," with ",[14,226,119],{}," set",[94,229,230,233,238,242],{},[112,231,232],{},"Other",[112,234,215,235],{},[14,236,237],{},"--id",[112,239,215,240],{},[14,241,218],{},[112,243,244],{},[19,245,247],{"href":246},"#other-ci-providers","Other providers",[249,250,252],"h3",{"id":251},"other-ci-providers","Other CI providers",[10,254,255,256,258,259,261],{},"Pass a stable ",[14,257,237],{}," on the base branch, and the same id as ",[14,260,218],{}," on pull request runs:",[263,264,269],"pre",{"language":265,"filename":266,"code":267,"class":268},"shell","Terminal","kubb studio snapshot --id jenkins:api:main # on main\nkubb studio snapshot --id jenkins:api:pr-12 --base-id jenkins:api:main # on a pull request","highlights",[14,270,272,299,300],{"class":271},"language-shell",[273,274,277,281,285,287,290,292,295],"span",{"class":275,"style":276},"line","display: inline",[273,278,280],{"style":279},"color:#6f42c1;--hls-dark:#b392f0","kubb ",[273,282,284],{"style":283},"color:#24292e;--hls-dark:#e1e4e8","studio snapshot --id jenkins",[273,286,86],{"style":283},[273,288,289],{"style":283},"api",[273,291,86],{"style":283},[273,293,294],{"style":283},"main ",[273,296,298],{"style":297},"color:#6a737d;--hls-dark:#6a737d","# on main","\n",[273,301,302,304,306,308,310,312,315,317,319,321,324],{"class":275,"style":276},[273,303,280],{"style":279},[273,305,284],{"style":283},[273,307,86],{"style":283},[273,309,289],{"style":283},[273,311,86],{"style":283},[273,313,314],{"style":283},"pr-12 --base-id jenkins",[273,316,86],{"style":283},[273,318,289],{"style":283},[273,320,86],{"style":283},[273,322,323],{"style":283},"main ",[273,325,326],{"style":297},"# on a pull request",[10,328,329,330,333,334,338,339,343],{},"To pass the tarball URL to another step, run ",[14,331,332],{},"kubb studio snapshot --json | jq -r '.url'",". See ",[19,335,337],{"href":336},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Fstudio#ci-agent-identity","CI agent identity"," and ",[19,340,342],{"href":341},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Fstudio#snapshot-output","Snapshot output"," for every field.",[42,345,347],{"id":346},"review-the-snapshot","Review the snapshot",[10,349,350,351,354,355,338,358,361],{},"Studio has no diff view for snapshots. The GitHub Action lists the changed files in its comment, and ",[14,352,353],{},"--json"," reports them in ",[14,356,357],{},"changes",[14,359,360],{},"branchChanges"," on any provider.",[10,363,364],{},"After the runner exits, open the CI agent's editor in Studio to read its latest unexpired package, comment on source lines, or preview generated HTML. Run the pipeline again to publish new output.",[366,367,369],"blockquote",{"as":368},"note","Snapshots expire after seven days. If the default branch can go a week without a push, schedule a run.",[42,371,373],{"id":372},"install-the-snapshot","Install the snapshot",[10,375,376,377,379,380,36],{},"Add the registry key to ",[14,378,137],{},", then run the install command from the snapshot result. pnpm and Yarn use the same URL and ",[14,381,137],{},[263,383,386],{"language":384,"filename":137,"code":385,"class":268},"ini","\u002F\u002Fkubb.studio\u002F:_authToken=${KUBB_REGISTRY_TOKEN}",[14,387,389],{"class":388},"language-ini",[273,390,391,394,397,401,404,407,410,413,415],{"class":275,"style":276},[273,392,393],{"style":283},"\u002F\u002Fkubb",[273,395,36],{"style":396},"color:#d73a49;--hls-dark:#f97583",[273,398,400],{"style":399},"color:#005cc5;--hls-dark:#79b8ff","studio",[273,402,403],{"style":283},"\u002F:_authToken",[273,405,406],{"style":396},"=",[273,408,409],{"style":283},"$",[273,411,412],{"style":399},"{",[273,414,133],{"style":399},[273,416,417],{"style":399},"}",[263,419,421],{"language":265,"filename":266,"code":420,"class":268},"npm i https:\u002F\u002Fkubb.studio\u002Fpackages\u002F\u003Cagent>\u002F\u003Cpackage>.tgz",[14,422,423],{"class":271},[273,424,425,428,431,433,436,439,442,445,448,450,453,455],{"class":275,"style":276},[273,426,427],{"style":279},"npm ",[273,429,430],{"style":283},"i https",[273,432,86],{"style":283},[273,434,435],{"style":283},"\u002F\u002Fkubb.studio\u002Fpackages\u002F",[273,437,438],{"style":396},"\u003C",[273,440,441],{"style":283},"agent",[273,443,444],{"style":396},">",[273,446,447],{"style":283},"\u002F",[273,449,438],{"style":396},[273,451,452],{"style":283},"package",[273,454,444],{"style":396},[273,456,457],{"style":283},".tgz",[10,459,460],{},"Yarn 1 also needs the registry for the package's scope, or the install fails with HTTP 403:",[263,462,464],{"language":384,"filename":137,"code":463,"class":268},"@\u003Cscope>:registry=https:\u002F\u002Fkubb.studio\u002F",[14,465,466],{"class":388},[273,467,468,471,473,476,478],{"class":275,"style":276},[273,469,470],{"style":283},"@\u003Cscope>:registry",[273,472,406],{"style":396},[273,474,475],{"style":283},"https:\u002F\u002Fkubb",[273,477,36],{"style":396},[273,479,480],{"style":283},"studio\u002F",{"title":482,"searchDepth":483,"depth":483,"links":484},"",5,[485,487,491,492],{"id":44,"depth":486,"text":45},2,{"id":155,"depth":486,"text":156,"children":488},[489],{"id":251,"depth":490,"text":252},3,{"id":346,"depth":486,"text":347},{"id":372,"depth":486,"text":373},"Run kubb studio snapshot in GitHub Actions, GitLab CI, or any CI to publish an installable package of your generated code per pull request.","md",{"layout":496,"title":5,"description":493,"outline":497,"order":486,"navigation":498},"doc",[486,490],{"title":499,"icon":500},"CI snapshots","i-iconoir-git-merge",{"layout":496,"outline":502},[486,490],{"title":499,"icon":500},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fci",{"title":5,"description":493},{"loc":504},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Fintegrations\u002Fci.md","docs\u002F5.x\u002Fintegrations\u002Fci","sVzQF4f-QnffXr7d1QAi3XwmdRIJ-5iGrEA3O2NmV8s",1795727674074,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]