Skip to content

[NO MERGE] feat: add jenkins agent selector logic to use env based agent#1441

Open
gunnertwin wants to merge 57 commits into
masterfrom
DTSPO-30107-jenkins-agents
Open

[NO MERGE] feat: add jenkins agent selector logic to use env based agent#1441
gunnertwin wants to merge 57 commits into
masterfrom
DTSPO-30107-jenkins-agents

Conversation

@gunnertwin

@gunnertwin gunnertwin commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Jira link

DTSPO-30107

Change description

This updates cnp-jenkins-library to run the standard app pipeline on environment-specific Jenkins agents and managed identities instead of the shared Jenkins agent identity.

The main app pipeline now selects a primary ubuntu- agent at startup, so checkout, build, static checks, container build, ACR promotion, Helm publish, and normal branch orchestration run on the relevant environment agent. Stages that target a different environment explicitly switch to that environment’s agent, for example preview AKS deploy/tests use ubuntu-preview, prod Terraform uses ubuntu-prod, and PTL Flux/Jenkins identity lookups use ubuntu-ptl.

This also updates Azure/AKS/ACR/DNS helpers so Azure CLI commands resolve the correct AZURE_CONFIG_DIR for the current environment agent, and keeps the existing shared-style paths only for backwards-compatible/custom paths where no product/environment is supplied.

Key changes:

  • Added AgentSelector and withEnvironmentAgent helpers for environment-to-agent selection.
  • Moved AKS deploy, smoke/functional tests, Helm uninstall, Terraform plan/apply, ACR build/promotion, Helm publish, and Flux reconcile onto environment-specific agents.
  • Updated withSubscription so Terraform setup runs on the target env agent, while Jenkins/PTL metadata lookup runs on the PTL agent.
  • Updated ACR, Helm, Kubectl, and private DNS helpers to use env-specific Azure config where appropriate.
  • Added tests for agent selection, Azure config resolution, ACR/Helm/Kubectl/DNS behaviour, and withSubscription env/PTL switching.

Testing done

Automated:

  • Ran ./gradlew test
  • Result: 299 passed, 0 failed

Manual Jenkins validation:

  • CFT Plum PR pipeline completed successfully using:
    • primary ubuntu-aat
    • preview deploy/test/uninstall on ubuntu-preview
    • no shared .azure-jenkins usage observed
  • SDS Toffee master pipeline completed successfully using:
    • primary ubuntu-stg
    • stg infra/deploy/test on ubuntu-stg
    • prod Terraform plan/apply on ubuntu-prod
    • PTL metadata/Flux reconcile on ubuntu-ptl
    • no shared .azure-jenkins usage observed

Validation also confirmed:

  • Terraform received non-empty TF_VAR_mgmt_subscription_id and TF_VAR_jenkins_AAD_objectId.
  • Environment MIs could access required Terraform state storage keys for the tested stg/prod flows.
  • Preview/stg AKS deploy, smoke, functional, DNS, and Helm uninstall paths worked end-to-end.

Security Vulnerability Assessment

CVE Suppression: Are there any CVEs present in the codebase, either newly introduced or pre-existing, that are being intentionally suppressed or ignored by this commit?

  • Yes
  • No

@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch 2 times, most recently from 6bc39ad to 2d1ef64 Compare April 30, 2026 13:49
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch 6 times, most recently from f959fc2 to 5587ecb Compare May 1, 2026 07:19
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from 5587ecb to 39898e8 Compare May 1, 2026 07:27
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from 3b7e7c6 to e7abf64 Compare May 5, 2026 11:08
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch 2 times, most recently from 00bf378 to b48042c Compare May 5, 2026 14:37
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from b48042c to 7f81b5e Compare May 5, 2026 14:57
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from 2d14631 to 592f687 Compare May 6, 2026 11:22
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch 3 times, most recently from 4b5e85e to cb1a146 Compare May 6, 2026 15:14
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from cb1a146 to 5baf788 Compare May 6, 2026 15:20
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from 84d379c to 6a366ff Compare May 7, 2026 14:53
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch 2 times, most recently from 1363b25 to 985f1c7 Compare June 5, 2026 13:43
@gunnertwin
gunnertwin force-pushed the DTSPO-30107-jenkins-agents branch from 36b4fc0 to 875adb8 Compare June 5, 2026 15:26
gunnertwin and others added 25 commits June 5, 2026 16:49
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Print output into jenkins view

* Allow branch for testing

* Update for correct object

* Update for correct object

* Improve output formatting

* Improve output formatting

* Improve output formatting

* Update formatting

* Update formatting

* Update formatting

* Update formatting

* Update formatting

* Update formatting

* Update formatting and instructions

* Fix failing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants