Chapter 11
Build and publish
Your button works in the showroom. It still lives only on your laptop. Publishing is the last mile: pack it up, check it, and hand it to the Pega server.
Pega 24 – 26
Words you will meet
- buildComponent
- publish
- Ruleset
The idea
Pack it, check it, post it.
Think of posting a parcel. You check the contents are what the label says (validate), you box it up (bundle), you write the address (ruleset and version), you confirm you really want to send it, and then it goes. One command, npm run publish, does all of it, and stops to ask you at the moments that matter.
Checklist
Before you press the button.
- The checks pass.
npm run verifyis green. - You are signed in.
npm run authenticatehas run, and the server address intasks.config.jsonis the one you mean. - The destination is right. Ruleset name and version match your application. Mixing these up is the most common publishing mistake.
- You chose the build type. Development while experimenting. Production only when it is final, because it cannot be deleted.
- The version moved forward. The component version in
config.jsonis the one you want on the server.
Play
One command, seven moments.
Run it below. The steps and the two confirmation questions are the real ones; the server and names are placeholders. Say No to a question at least once, so you see that nothing is sent until you agree.
- ValidateChecks config.json against the component rules.
- BundlePacks your code and its styles into one deliverable file.
- Choose whereTakes the ruleset and version from your config (or asks).
- ConfirmShows the server and asks you to say yes.
- UploadSends the bundle to the Pega server.
- SavedPega stores it as a rule in your ruleset version.
$ npm run publish
Illustrative output with placeholder values. Your own run prints your real server and application.
Reference
The commands.
# Validate and build, without publishing. A dry run for the bundle.npm run buildComponent -- --name=Acme_UI_CelebrateButtonnpm run buildAllComponents # Publish one component. It asks for ruleset, version and build type.npm run publish -- Acme_UI_CelebrateButton # Skip the questions: component, ruleset, version, then Y (development) or N.npm run publish -- Acme_UI_CelebrateButton AcmeComponents 01-01-01 Y # Publish everything that is built.npm run publishAllThe one-line form comes from reading the tool's source, not from a run. Try it with a development build first.
Play
Or use the Deployment Hub.
If commands are not your thing, start npm run hub and use a web page instead. It reads the servers you listed in hub.config.json and publishes with buttons. This is a model of it: choose a server, press Publish, and watch the runs list grow. Try Stop while one is running.
Ruleset
AcmeComponents
Build: dev (from the server's entry in hub.config.json)
Runs
Nothing yet. Press Publish or Validate.
- Publish
- Builds and publishes one component, or all of them, to any server in your config.
- Validate
- Runs the schema checks without a full publish. A quick sanity pass.
- Sign in
- OAuth sign-in per server, remembered on your machine.
- Stop
- Aborts a run mid-flight, after a confirmation. What was already sent to the server stays there.
- Terminal
- Each run is a collapsible block with its own status, command, duration and output.
- Run history
- Earlier runs load when the page opens. A failed run stays open so you can read why.
Fine print
What you are signing up for.
The builder prints a note whenever you list its commands, and it is worth reading once. In its own words, by choosing to create and use custom components you agree to keep them up to date with every release of Pega Infinity, and to meet compliance standards for data privacy and accessibility.
In practice: when your Pega server is upgraded, rebuild with the matching builder (see the version table on the start page) and republish. A component is software, and software needs looking after. Your button is not done; it is shipped.
One more thing the builder mentions: it also has a library mode for bundling many components into a versioned library. It is labelled beta and experimental in the tool itself, so this guide, and this project, use the ordinary component mode.
Your turn
Questions and comments
Stuck on something, or have a thought? Write it here. To talk about one part, use the Comment button under that section's heading.