Support custom labels on GCE agent VMs#551
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Need to create a tracking issue and then will take this out of draft |
one exists - #170 😄 need to also update the user visible documentation for this feature usage |
There was a problem hiding this comment.
Pull request overview
Adds support for configuring custom GCP instance labels (key/value pairs) on provisioned GCE agent VMs, exposed via both Jenkins UI and Configuration as Code, with test coverage across unit, CasC, and integration layers.
Changes:
- Introduces
CustomLabelItemand wirescustomLabelsintoInstanceConfigurationand the Jenkins configuration UI. - Merges configured custom labels into the instance label map during provisioning.
- Adds/extends unit tests, CasC round-trip assertions, and an integration test to verify labels land on real instances.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java |
Adds customLabels and folds them into the effective label map during instance creation. |
src/main/java/com/google/jenkins/plugins/computeengine/CustomLabelItem.java |
New describable for a single label key/value pair. |
src/main/resources/com/google/jenkins/plugins/computeengine/InstanceConfiguration/config.jelly |
Exposes a repeatable “Custom labels” section in the instance configuration UI. |
src/main/resources/com/google/jenkins/plugins/computeengine/CustomLabelItem/config.jelly |
UI fragment for editing a label key/value entry. |
src/test/java/com/google/jenkins/plugins/computeengine/InstanceConfigurationTest.java |
Adds unit tests for label folding behavior (including skipping empty keys and preserving system label). |
src/test/java/com/google/jenkins/plugins/computeengine/ConfigAsCodeTest.java |
Extends CasC assertions to cover customLabels. |
src/test/java/com/google/jenkins/plugins/computeengine/integration/ComputeEngineCloudCustomLabelsIT.java |
New integration test that provisions a VM and asserts the instance labels. |
src/test/resources/com/google/jenkins/plugins/computeengine/configuration-as-code.yml |
Adds example customLabels configuration for CasC tests. |
src/test/resources/com/google/jenkins/plugins/computeengine/integration/custom-labels-casc.yml |
New CasC bundle used by the integration test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gbhat618
left a comment
There was a problem hiding this comment.
lgtm; a couple of comments about tests.
also need readme updates to mention the new user visible feature
- Replace sleep with SemaphoreStep in CustomLabelsIT to avoid flakiness - Drop testInstanceNullCustomLabels (redundant) - Suppress HARD_CODE_PASSWORD false positive on CustomLabelItem.key Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…m.key Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
PR looks good to me, I have reviewed the new commits. I will allocate some 30min post lunch and if all is good, I will proceed to merge the PR. 🎉 |
|
Tested, works 🎉 . thank you @mikecirioli
|

Closes #170
What this does
Adds support for setting custom GCP labels (key-value pairs) on the GCE agent VMs the plugin provisions. This is the plugin equivalent of
gcloud compute instances create --labels=[KEY=VALUE,...], and mirrors the existing custom metadata feature.Labels differ from metadata: a label value is a single word with no spaces (max 63 chars), so the value field is a single-line text box rather than a textarea. Per the existing GCE convention, there is no
doCheckXXXform validation - GCP rejects invalid labels at instance-creation time.How it works
A new
CustomLabelItemdescribable holds each key-value pair.InstanceConfigurationgains an optionalcustomLabelslist, exposed in the form UI and via Configuration as Code. The labels are folded into the instance's label map before the system labels are applied, so user labels never clobber the plugin's internal labels, and template-defined labels keep their existing precedence.CasC example:
UI
Testing
customLabelspersists through the form.ComputeEngineCloudCustomLabelsIT) that provisions a real VM via CasC and asserts the labels land on the instance.Verified end to end on a live cluster: the configured labels appear on the provisioned GCE VM alongside the plugin's system labels.
🤖 Generated with Claude Code