Skip to content

t1k:jenkins-test-pipeline

FieldValue
Modulet1k-devops
Version4.1.3
Effortmedium
Tools—

Keywords: CocosJenkinsScripts, folder library, groovy scripts, jenkins, jenkins-helper, JenkinsScripts, library branch, per-person folder, pipeline branch, RNJenkinsScripts, shared library, test pipeline, testpipeline

/t1k:jenkins-test-pipeline
<person-slug> --repo <library-repo-url> --branch <library-branch> [--jobs <TestPipeline job>...]

Test a pipeline-library branch in a per-person TestPipeline folder

Section titled “Test a pipeline-library branch in a per-person TestPipeline folder”

Game Jenkinsfiles do @Library('jenkins-helper') _. Jenkins resolves that name at the nearest folder that defines it. The shared TestPipeline folder points jenkins-helper at ONE library repo and branch, so two people testing two branches clobber each other. Fix: give each person a TestPipeline/<person> folder with its own jenkins-helper entry; jobs inside it load the library from that person’s branch, jobs elsewhere are untouched.

The shared folder’s library is live state, not a constant. It may point at a branch of ANY engine’s library (it has pointed at CocosJenkinsScripts on a review branch), so a job created directly in TestPipeline inherits that library whatever its own engine. Never create an ad-hoc job there: read the entry first (get-config "" TestPipeline --out f.xml), and for a job whose engine differs from it, or when unsure, use a per-person folder with --repo set to the engine’s library (Unity JenkinsScripts). There is no library-less folder: create-folder always clones and rewrites a jenkins-helper entry, so the engine’s own library is the closest a test job gets.

All Jenkins calls go through t1k-jenkins-job’s scripts/jenkins-job.cjs (auth resolution and gotchas live there). This skill adds the flow; do not hand-roll curl.

Terminal window
S=~/.claude/skills/t1k-jenkins-job/scripts/jenkins-job.cjs
  1. Chọn slug của bạn (kebab-case, vd tuha), repo thư viện và nhánh cần test.
  2. bun $S create-folder TestPipeline <slug> --repo <repo> --branch <nhánh> --dry-run, xem rồi bỏ --dry-run.
  3. Copy job cần test vào TestPipeline/<slug> (xem Flow bước 4), build thử một lần, kiểm tra log có Loading library jenkins-helper@<nhánh>.
  4. Xong việc: trả nhánh về hoặc xoá folder (hỏi user trước, xem Cleanup).
InputSource
person slug[a-z0-9-]; default from git config user.name, kebab-cased. Confirm with the user.
library repoUnity git@github.com:The1Studio/JenkinsScripts.git (GroovyScripts/), Cocos CocosJenkinsScripts, RN RNJenkinsScripts
library branchthe branch under test
jobs to copynames of existing TestPipeline jobs, or a spec via t1k-jenkins-unity / t1k-jenkins-cocos

Ask the open ones in ONE AskUserQuestion (slug, repo, branch, jobs, Discord thread ID).

  1. Pre-check the branch. git ls-remote --heads <repo> <branch> must be non-empty; run the library’s own CI gate (ci/ in the library repo) if it has one. Stop on a missing branch.
  2. Collision check. bun $S list TestPipeline --grep <slug>. Folder exists: go to step 3b.
  3. Create or repoint the folder.
    • 3a new: bun $S create-folder TestPipeline <slug> --repo <repo> --branch <branch> --dry-run, show the printed before/after, then rerun without --dry-run. It clones the TestPipeline folder config and rewrites only the jenkins-helper url, BranchSpec and defaultVersion.
    • 3b existing (switch branch): bun $S set-folder-library TestPipeline/<slug> --branch <branch> --dry-run, then without --dry-run; the command reads the config back and prints it.
  4. Copy jobs into the folder, per job: get-config TestPipeline <job> --out t.xml -> gen --base t.xml --out j.xml --strip-triggers -> create TestPipeline/<slug> <job> --from j.xml. Test jobs never build on push. Never inherit a thread ID: AskUserQuestion for PARAM_DISCORD_THREAD_ID first (see t1k-jenkins-job, “Never inherit a thread ID”), then --set PARAM_DISCORD_THREAD_ID=<id>. More than one job: smoke ONE, show it, then the rest (preview-first-batch).
  5. Verify off the server. Folder: get-config TestPipeline <slug> --out f.xml and read the jenkins-helper entry. Jobs: verify TestPipeline/<slug> <job> --expect-triggers no. Trigger a build only on the user’s OK, then confirm the console log contains Loading library jenkins-helper@... and that the checkout is <repo> at <branch>. A 200 from POST proves nothing.
  6. Cleanup when the branch merges: repoint (set-folder-library ... --branch master) or delete the folder. Deleting is destructive and often not permitted for CI accounts: ask the user, never create-then-delete scratch items.

Details, XML shape and what is verified vs unverified: references/folder-library.md.

  • Credentials: the cloned library keeps the parent’s credentialsId; a repo in another org may fail only at first build.

Per-person library-branch testing in TestPipeline. Not for: editing Jenkinsfiles or library code, creating production jobs (use t1k-jenkins-unity / t1k-jenkins-cocos), deleting items, managing credentials.