diff --git a/agent-ops/rules/project/domain/sample/rules.md b/agent-ops/rules/project/domain/sample/rules.md new file mode 100644 index 0000000..fc800a8 --- /dev/null +++ b/agent-ops/rules/project/domain/sample/rules.md @@ -0,0 +1,73 @@ +# sample + +## 목적 / 책임 + +YAML 작성 요청 시 코드 분석 없이 빠르게 참조할 수 있는 샘플 파일 모음을 담당한다. +샘플만 읽으면 파라미터 이름·태그 문법·파이프라인 패턴을 바로 파악할 수 있어 토큰을 절약한다. + +## 포함 경로 + +- `assets/yaml/sample/` — 카테고리별 샘플 YAML 파일 + +## 제외 경로 + +- `assets/yaml/example/` — 기존 실험용 파일 (샘플 도메인 아님) +- `assets/templates/` — 알림 템플릿 (샘플 도메인 아님) + +## 주요 구성 요소 + +| 파일 | 다루는 커맨드 / 패턴 | +|------|-------------------| +| `01_basic.yaml` | property, SetValue, Print — 기본 구조 | +| `02_pipeline_if.yaml` | if (string/int/version 타입 조건 분기) | +| `03_pipeline_foreach.yaml` | foreach (List·Map 순회, 중첩) | +| `04_pipeline_exe_handle.yaml` | exe-handle (on-success / on-fail) | +| `05_pipeline_while_switch.yaml` | while, switch, wait-until | +| `06_git.yaml` | Git, GitCommit, GitPush, GitRev, GitCount, GitBranch | +| `07_file.yaml` | Copy, Delete, FileRead, FileWrite, Zip, FileInfo | +| `08_notification.yaml` | Slack, SlackBuild, Mattermost, MattermostBuild | +| `09_network.yaml` | WebRequest, WebFile, Upload(FTP), Download(FTP) | +| `10_build_ios.yaml` | BuildiOS, ArchiveiOS, ExportiOS, TestflightUpload, TestflightDistribute | +| `11_build_flutter.yaml` | BuildFlutter (멀티플랫폼) | +| `12_scheduler.yaml` | scheduler 섹션 (cron / interval) | +| `13_string_json.yaml` | StringSub, StringReplace, JsonReader, JsonReaderFile, JsonWriterFile | +| `14_shell_process.yaml` | Shell, ShellFile, ProcessRun, ProcessKill, ProcessPortUse | + +## YAML 작성 요청 시 참조 가이드 + +요청 내용에 따라 아래 샘플만 읽으면 충분하다. 코드를 읽지 않는다. + +| 요청 키워드 | 읽을 샘플 | +|------------|---------| +| iOS 빌드, Archive, TestFlight | `10_build_ios.yaml` | +| Flutter 빌드 | `11_build_flutter.yaml` | +| Git, 커밋, 푸시, 브랜치 | `06_git.yaml` | +| 파일 복사, 압축, 삭제 | `07_file.yaml` | +| Slack, Mattermost 알림 | `08_notification.yaml` | +| HTTP, FTP, 네트워크 | `09_network.yaml` | +| if 분기 | `02_pipeline_if.yaml` | +| foreach, 반복 | `03_pipeline_foreach.yaml` | +| 성공/실패 분기 | `04_pipeline_exe_handle.yaml` | +| while, switch | `05_pipeline_while_switch.yaml` | +| 스케줄러 | `12_scheduler.yaml` | +| 문자열, JSON | `13_string_json.yaml` | +| 셸, 프로세스 | `14_shell_process.yaml` | +| 처음 만드는 파이프라인, 기본 구조 | `01_basic.yaml` | + +## 유지할 패턴 + +- 파일명은 `NN_카테고리.yaml` 형식 (번호 + 언더스코어 + 카테고리) +- 각 파일 상단에 `# [샘플] 제목` 주석으로 목적 명시 +- 실제 작동 가능한 파라미터 구조를 유지한다 (추측 값 사용 금지) +- 새 커맨드가 추가되면 관련 샘플 파일도 함께 갱신한다 + +## 다른 도메인과의 경계 + +- **command**: 커맨드 파라미터가 변경되면 샘플도 동기화 필요. 샘플은 command 도메인을 참조하지 않는다 +- **core**: 태그 문법(`` / `<@...>`)이 변경되면 모든 샘플 파일 업데이트 필요 + +## 금지 사항 + +- 실제 코드(Dart 파일)를 읽어 파라미터를 추론하지 않는다 — 샘플에서 직접 읽는다 +- 샘플에 실제 토큰·비밀번호·API 키를 기재하지 않는다 (placeholder 사용) +- 존재하지 않는 커맨드나 파라미터를 샘플에 넣지 않는다 diff --git a/agent-ops/rules/project/rules.md b/agent-ops/rules/project/rules.md index 8512331..e8738bc 100644 --- a/agent-ops/rules/project/rules.md +++ b/agent-ops/rules/project/rules.md @@ -86,3 +86,4 @@ lib/ | `lib/oto/core/**` | core | `agent-ops/rules/project/domain/core/rules.md` | | `lib/oto/utils/**` | core | `agent-ops/rules/project/domain/core/rules.md` | | `lib/framework/**` | framework | `agent-ops/rules/project/domain/framework/rules.md` | +| `assets/yaml/sample/**` | sample | `agent-ops/rules/project/domain/sample/rules.md` | diff --git a/agent-ops/skills/common/router.md b/agent-ops/skills/common/router.md index c908256..f517cd1 100644 --- a/agent-ops/skills/common/router.md +++ b/agent-ops/skills/common/router.md @@ -10,3 +10,4 @@ | 커밋해줘, 푸시해줘, commit, push, 반영해줘 | `agent-ops/skills/common/commit-push/SKILL.md` | | agent-ops 싱크해, agent-ops 동기화해, agentic-framework에 올려줘, agent-ops를 [프로젝트]로 싱크해 | `agent-ops/skills/common/sync-agent-ops/SKILL.md` | | 도메인 업데이트, domain rule 갱신, 도메인 검토, domain 스캔 | `agent-ops/skills/common/update-domain-rule/SKILL.md` | +| yaml 짜줘, 파이프라인 만들어줘, 자동화 작성, 빌드 yaml | `agent-ops/rules/project/domain/sample/rules.md` 읽고 해당 샘플 참조 | diff --git a/assets/yaml/sample/01_basic.yaml b/assets/yaml/sample/01_basic.yaml new file mode 100644 index 0000000..48bc10e --- /dev/null +++ b/assets/yaml/sample/01_basic.yaml @@ -0,0 +1,37 @@ +--- +# [샘플] 기본 구조 +# property, commands, pipeline 세 섹션으로 구성된다. +# pipeline의 exe는 commands의 id를 참조한다. + +property: + workspace: /path/to/project + env: dev + version: 1.0.0 + +pipeline: + id: main + workflow: + - exe: print-start + - exe: set-value + - exe: print-result + +commands: +- command: Print + id: print-start + param: + message: "빌드 시작 - env: , version: " + +- command: SetValue + id: set-value + param: + values-string: + buildTag: "v-" + values-int: + retryCount: 0 + values-bool: + isRelease: false + +- command: Print + id: print-result + param: + message: "빌드 태그: " diff --git a/assets/yaml/sample/02_pipeline_if.yaml b/assets/yaml/sample/02_pipeline_if.yaml new file mode 100644 index 0000000..3d9157f --- /dev/null +++ b/assets/yaml/sample/02_pipeline_if.yaml @@ -0,0 +1,53 @@ +--- +# [샘플] 조건 분기 (if) +# condition-string / condition-int / condition-float / condition-bool / +# condition-date / condition-version 으로 타입 지정 +# on-true / on-false 로 분기 + +property: + workspace: /path/to/project + env: prod + +pipeline: + id: main + workflow: + # string 비교 + - if: + condition-string: == prod + on-true: + - exe: deploy-prod + on-false: + - exe: deploy-dev + + # int 비교 + - if: + condition-int: < 3 + on-true: + - exe: retry-build + + # version 비교 (자릿수 동일해야 함: 0.0.0 or 0.0.0.0) + - if: + condition-version: >= 2.0.0 + on-true: + - exe: new-flow + +commands: +- command: Print + id: deploy-prod + param: + message: "운영 배포 실행" + +- command: Print + id: deploy-dev + param: + message: "개발 배포 실행" + +- command: Print + id: retry-build + param: + message: "재시도 실행" + +- command: Print + id: new-flow + param: + message: "신규 플로우 실행" diff --git a/assets/yaml/sample/03_pipeline_foreach.yaml b/assets/yaml/sample/03_pipeline_foreach.yaml new file mode 100644 index 0000000..6ef4bb3 --- /dev/null +++ b/assets/yaml/sample/03_pipeline_foreach.yaml @@ -0,0 +1,60 @@ +--- +# [샘플] 반복 (foreach) +# iterator: List 또는 Map +# setValue: 현재 값 저장 태그 +# setKey: Map 순회 시 key 저장 태그 (optional) + +property: + workspace: /path/to/project + platforms: + - ios + - android + envMap: + dev: https://dev.example.com + prod: https://prod.example.com + +pipeline: + id: main + workflow: + # List 순회 + - foreach: + iterator: + setValue: <@property.platform> + on-do: + - exe: print-platform + + # Map 순회 (key + value) + - foreach: + iterator: + setKey: <@property.envName> + setValue: <@property.envUrl> + on-do: + - exe: print-env + + # 중첩 foreach + - foreach: + iterator: + setValue: <@property.platform> + on-do: + - foreach: + iterator: + setKey: <@property.envName> + setValue: <@property.envUrl> + on-do: + - exe: print-matrix + +commands: +- command: Print + id: print-platform + param: + message: "플랫폼: " + +- command: Print + id: print-env + param: + message: "환경: " + +- command: Print + id: print-matrix + param: + message: " / : " diff --git a/assets/yaml/sample/04_pipeline_exe_handle.yaml b/assets/yaml/sample/04_pipeline_exe_handle.yaml new file mode 100644 index 0000000..6441fc8 --- /dev/null +++ b/assets/yaml/sample/04_pipeline_exe_handle.yaml @@ -0,0 +1,46 @@ +--- +# [샘플] 성공/실패 분기 (exe-handle) +# on-success: 커맨드가 성공(exit 0)했을 때 +# on-fail: 커맨드가 실패(exit 非0)했을 때 +# passExitCodes: 성공으로 간주할 exit code 추가 지정 + +property: + workspace: /path/to/project + +pipeline: + id: main + workflow: + - exe-handle: + id: build-ios + on-success: + - exe: notify-success + - exe: upload-artifact + on-fail: + - exe: notify-fail + +commands: +- command: BuildiOS + id: build-ios + param: + workspacePath: /ios/Runner.xcworkspace + scheme: Runner + destination: "generic/platform=iOS" + +- command: Slack + id: notify-success + param: + token: xoxb-your-slack-token + channel: "#builds" + message: "✅ iOS 빌드 성공" + +- command: Slack + id: notify-fail + param: + token: xoxb-your-slack-token + channel: "#builds" + message: "❌ iOS 빌드 실패" + +- command: Print + id: upload-artifact + param: + message: "아티팩트 업로드 중..." diff --git a/assets/yaml/sample/05_pipeline_while_switch.yaml b/assets/yaml/sample/05_pipeline_while_switch.yaml new file mode 100644 index 0000000..a462ac4 --- /dev/null +++ b/assets/yaml/sample/05_pipeline_while_switch.yaml @@ -0,0 +1,66 @@ +--- +# [샘플] 루프(while) + 멀티케이스(switch) + +property: + workspace: /path/to/project + retryCount: 0 + maxRetry: 3 + status: pending + +pipeline: + id: main + workflow: + # while: 조건이 참인 동안 반복 + - while: + condition-int: < + on-do: + - exe: check-status + - exe: increment-retry + + # switch: 값에 따라 분기 + - switch: + condition-string: + cases: + - value: success + tasks: + - exe: notify-success + - value: failed + tasks: + - exe: notify-fail + - value: pending + tasks: + - exe: notify-pending + + # wait-until: 비동기 작업 완료 대기 + # - async: long-running-task + # - wait-until-string: == complete + + # wait-until-seconds: N초 단순 대기 + # - wait-until-seconds: 30 + +commands: +- command: Print + id: check-status + param: + message: "상태 확인 중... (시도: )" + +- command: SetValue + id: increment-retry + param: + values-int: + retryCount: 1 + +- command: Print + id: notify-success + param: + message: "성공" + +- command: Print + id: notify-fail + param: + message: "실패" + +- command: Print + id: notify-pending + param: + message: "대기중" diff --git a/assets/yaml/sample/06_git.yaml b/assets/yaml/sample/06_git.yaml new file mode 100644 index 0000000..1c43cee --- /dev/null +++ b/assets/yaml/sample/06_git.yaml @@ -0,0 +1,76 @@ +--- +# [샘플] Git 작업 + +property: + workspace: /path/to/project + branch: main + commitMessage: "chore: automated update" + +pipeline: + id: main + workflow: + - exe: git-update # 최신 소스로 업데이트 + - exe: git-rev # 현재 리비전 저장 + - exe: git-count # 커밋 수 저장 + - exe: print-info + # 변경사항이 있을 때만 커밋 + 푸시 + - if: + condition-bool: == true + on-true: + - exe: git-commit + - exe: git-push + +commands: +# 임의 git 명령 조합 +- command: Git + id: git-update + param: + commands: + - fetch origin + - reset --hard origin/ + - clean -fd + +# 브랜치 체크아웃 +- command: GitCheckout + id: git-checkout + param: + branch: + execute-pull: true + +# 현재 리비전 해시 저장 +- command: GitRev + id: git-rev + param: + result-value: <@property.gitRev> + +# 전체 커밋 수 저장 +- command: GitCount + id: git-count + param: + result-value: <@property.gitCount> + +- command: Print + id: print-info + param: + message: "rev: , count: " + +# 변경 파일 스테이징 + 커밋 +- command: GitCommit + id: git-commit + param: + message: + addNewFile: true + +# 원격 브랜치에 푸시 +- command: GitPush + id: git-push + param: + branch: + +# 브랜치 목록 조회 (최근 N일) +- command: GitBranch + id: git-branch-list + param: + path: + startDay: 30 + setBranches: <@property.branches> diff --git a/assets/yaml/sample/07_file.yaml b/assets/yaml/sample/07_file.yaml new file mode 100644 index 0000000..453e9b1 --- /dev/null +++ b/assets/yaml/sample/07_file.yaml @@ -0,0 +1,85 @@ +--- +# [샘플] 파일 조작 + +property: + workspace: /path/to/project + version: 1.0.0 + +pipeline: + id: main + workflow: + - exe: read-config # 파일 읽기 + - exe: string-replace # 내용 치환 + - exe: write-config # 파일 쓰기 + - exe: copy-release # 복사 + - exe: zip-release # 압축 + - exe: delete-temp # 임시 파일 삭제 + +commands: +# 파일 전체 내용 읽기 → property 저장 +- command: FileRead + id: read-config + param: + path: /config/app.conf + setContent: <@property.configContent> + showPrint: false + +# 문자열 치환 +- command: StringReplace + id: string-replace + param: + text: + pair: + - from: "VERSION_PLACEHOLDER" + to: + - from: "ENV_PLACEHOLDER" + to: prod + setValue: <@property.configContent> + +# 파일에 내용 쓰기 +- command: FileWrite + id: write-config + param: + path: /build/app.conf + content: + +# 파일/디렉토리 복사 (copyMap: from → to) +- command: Copy + id: copy-release + param: + ignorePattern: + - "*.log" + - ".DS_Store" + copyMap: + "/build/*": "/release" + +# 이동 (isMove: true) +# - command: Copy +# id: move-file +# param: +# isMove: true +# copyMap: +# "/tmp/output": "/release" + +# 압축 +- command: Zip + id: zip-release + param: + zipFile: "/dist/release_v.zip" + zipList: + - "/release" + +# 파일/디렉토리 삭제 +- command: Delete + id: delete-temp + param: + list: + - "/tmp" + - "/build" + +# 파일 메타데이터 조회 +- command: FileInfo + id: file-info + param: + path: "/dist/release_v.zip" + setInfo: <@property.fileInfo> diff --git a/assets/yaml/sample/08_notification.yaml b/assets/yaml/sample/08_notification.yaml new file mode 100644 index 0000000..5afe1e9 --- /dev/null +++ b/assets/yaml/sample/08_notification.yaml @@ -0,0 +1,67 @@ +--- +# [샘플] 알림 (Slack / Mattermost) + +property: + workspace: /path/to/project + appName: MyApp + version: 1.0.0 + downloadURL: https://example.com/download/MyApp.ipa + +pipeline: + id: main + workflow: + - exe: slack-message + - exe: slack-build-report + - exe: mattermost-message + - exe: mattermost-build-report + +commands: +# Slack 텍스트 메시지 +- command: Slack + id: slack-message + param: + token: xoxb-your-slack-bot-token + channel: "#ci-builds" + message: "배포 시작: v" + +# Slack 파일 업로드 +# - command: SlackFile +# id: slack-file +# param: +# token: xoxb-your-slack-bot-token +# channel: "#ci-builds" +# filePath: /output/result.txt +# message: "빌드 결과 로그" + +# Slack 빌드 결과 리포트 (구조화된 메시지) +- command: SlackBuild + id: slack-build-report + param: + token: xoxb-your-slack-bot-token + channel: "#ci-builds" + appName: + type: ios + version: + downloadURL: + +# Mattermost 텍스트 메시지 +- command: Mattermost + id: mattermost-message + param: + url: https://mattermost.example.com/api/v4/posts + token: your-mattermost-token + channelId: your-channel-id + message: "배포 완료: v" + +# Mattermost 빌드 결과 리포트 +- command: MattermostBuild + id: mattermost-build-report + param: + url: https://mattermost.example.com/api/v4/posts + token: your-mattermost-token + channelId: your-channel-id + appName: + type: ios + color: 45C45E + version: + downloadURL: diff --git a/assets/yaml/sample/09_network.yaml b/assets/yaml/sample/09_network.yaml new file mode 100644 index 0000000..f364d4c --- /dev/null +++ b/assets/yaml/sample/09_network.yaml @@ -0,0 +1,80 @@ +--- +# [샘플] 네트워크 / HTTP / FTP + +property: + workspace: /path/to/project + +pipeline: + id: main + workflow: + - exe: http-get # HTTP GET → 응답 저장 + - exe: json-parse # 응답 JSON 파싱 + - exe: http-post # HTTP POST + - exe: ftp-upload # FTP 업로드 + - exe: ftp-download # FTP 다운로드 + - exe: download-file # HTTP 파일 다운로드 + +commands: +# HTTP GET, 응답 body 저장 +- command: WebRequest + id: http-get + param: + url: https://api.example.com/status + method: GET + headers: + Authorization: Bearer your-token + setResponse: <@property.apiResponse> + +# 응답 JSON에서 값 추출 +- command: JsonReader + id: json-parse + param: + json: + pair: + - from: status + setValue: <@property.apiStatus> + - from: version + setValue: <@property.serverVersion> + +# HTTP POST +- command: WebRequest + id: http-post + param: + url: https://api.example.com/deploy + method: POST + headers: + Content-Type: application/json + Authorization: Bearer your-token + body: + appId: com.example.app + version: + setResponse: <@property.deployResponse> + +# HTTP 파일 다운로드 +- command: WebFile + id: download-file + param: + url: https://example.com/tools/tool.zip + savePath: /tools/tool.zip + +# FTP 업로드 (copyMap: local → remote) +- command: Upload + id: ftp-upload + param: + host: ftp.example.com + port: 21 + id: ftp-user + password: ftp-password + copyMap: + "/release/app.ipa": "/public/releases/app.ipa" + +# FTP 다운로드 (copyMap: remote → local) +- command: Download + id: ftp-download + param: + host: ftp.example.com + port: 21 + id: ftp-user + password: ftp-password + copyMap: + "/public/config/app.json": "/config/app.json" diff --git a/assets/yaml/sample/10_build_ios.yaml b/assets/yaml/sample/10_build_ios.yaml new file mode 100644 index 0000000..a84e121 --- /dev/null +++ b/assets/yaml/sample/10_build_ios.yaml @@ -0,0 +1,104 @@ +--- +# [샘플] iOS 전체 빌드 파이프라인 +# Build → Archive → Export → TestFlight 업로드 → 배포 + +property: + workspace: /path/to/project + scheme: Runner + configuration: Release + version: 1.0.0 + exportOptionsPath: /ios/ExportOptions.plist + archivePath: /build/Runner.xcarchive + exportPath: /build/export + ipaPath: /Runner.ipa + +pipeline: + id: main + workflow: + - exe: build-ios + - exe-handle: + id: archive-ios + on-success: + - exe: export-ios + - exe: upload-testflight + - exe: check-testflight + - exe: distribute-testflight + - exe: notify-success + on-fail: + - exe: notify-fail + +commands: +# xcodebuild build (시뮬레이터 테스트용) +- command: BuildiOS + id: build-ios + param: + # xcworkspace 우선, 없으면 xcodeproj 사용 + workspacePath: /ios/Runner.xcworkspace + scheme: + configuration: + destination: "generic/platform=iOS Simulator" + +# xcodebuild archive +- command: ArchiveiOS + id: archive-ios + param: + workspacePath: /ios/Runner.xcworkspace + scheme: + configuration: + archivePath: + +# .xcarchive → .ipa export +- command: ExportiOS + id: export-ios + param: + archivePath: + exportPath: + exportOptionsPlist: + +# TestFlight 업로드 (altool / notarytool) +- command: TestflightUpload + id: upload-testflight + param: + ipaPath: + username: apple-id@example.com + password: "@keychain:app-specific-password" + +# 처리 완료 대기 +- command: TestflightStatusCheck + id: check-testflight + param: + username: apple-id@example.com + password: "@keychain:app-specific-password" + bundleId: com.example.app + version: + +# 테스터 그룹에 배포 +- command: TestflightDistribute + id: distribute-testflight + param: + username: apple-id@example.com + password: "@keychain:app-specific-password" + bundleId: com.example.app + version: + groups: + - Internal Testers + +- command: MattermostBuild + id: notify-success + param: + url: https://mattermost.example.com/api/v4/posts + token: your-mattermost-token + channelId: your-channel-id + appName: MyApp + type: ios + color: 45C45E + version: + downloadURL: https://testflight.apple.com/join/xxxxxx + +- command: Mattermost + id: notify-fail + param: + url: https://mattermost.example.com/api/v4/posts + token: your-mattermost-token + channelId: your-channel-id + message: "❌ iOS 빌드 실패 - v" diff --git a/assets/yaml/sample/11_build_flutter.yaml b/assets/yaml/sample/11_build_flutter.yaml new file mode 100644 index 0000000..b893d5a --- /dev/null +++ b/assets/yaml/sample/11_build_flutter.yaml @@ -0,0 +1,55 @@ +--- +# [샘플] Flutter 멀티플랫폼 빌드 + +property: + workspace: /path/to/flutter_project + version: 1.0.0 + flavor: production + platforms: + - ios + - android + +pipeline: + id: main + workflow: + - exe: git-update + - foreach: + iterator: + setValue: <@property.platform> + on-do: + - if: + condition-string: == ios + on-true: + - exe: build-ios + on-false: + - exe: build-android + - exe: notify-done + +commands: +- command: Git + id: git-update + param: + commands: + - fetch origin + - reset --hard origin/main + +- command: BuildFlutter + id: build-ios + param: + targetPath: + platform: ios + flavor: + additional: "--release --no-codesign" + +- command: BuildFlutter + id: build-android + param: + targetPath: + platform: android + flavor: + additional: "--release" + +- command: Print + id: notify-done + param: + message: " 빌드 완료" diff --git a/assets/yaml/sample/12_scheduler.yaml b/assets/yaml/sample/12_scheduler.yaml new file mode 100644 index 0000000..3118c94 --- /dev/null +++ b/assets/yaml/sample/12_scheduler.yaml @@ -0,0 +1,40 @@ +--- +# [샘플] 스케줄러 설정 +# oto scheduler -r 12_scheduler.yaml 으로 등록 +# oto scheduler -l 으로 목록 확인 +# oto scheduler -u nightly-build 으로 해제 + +scheduler: + alias: nightly-build + cron: "0 2 * * *" # 매일 새벽 2시 (cron 형식) + # interval: 3600000 # 또는 ms 단위 interval (1시간) + enableLog: true # 로그 파일 기록 여부 + +property: + workspace: /path/to/project + branch: main + version: 1.0.0 + +pipeline: + id: main + workflow: + - exe: git-update + - exe: build + - exe: notify + +commands: +- command: Git + id: git-update + param: + commands: + - fetch origin + - reset --hard origin/ + +- command: BuildDart + id: build + param: {} + +- command: Print + id: notify + param: + message: "나이틀리 빌드 완료" diff --git a/assets/yaml/sample/13_string_json.yaml b/assets/yaml/sample/13_string_json.yaml new file mode 100644 index 0000000..3575be0 --- /dev/null +++ b/assets/yaml/sample/13_string_json.yaml @@ -0,0 +1,96 @@ +--- +# [샘플] 문자열 처리 + JSON 읽기/쓰기 + +property: + workspace: /path/to/project + rawVersion: "v1.2.3-release" + payload: '{"status": "ok", "build": {"version": "1.2.3", "number": 42}}' + +pipeline: + id: main + workflow: + - exe: string-sub # 부분 문자열 추출 + - exe: string-replace # 문자열 치환 + - exe: string-pattern # 정규식 치환 + - exe: string-index # 인덱스 검색 + - exe: json-read # JSON 값 추출 + - exe: json-read-file # JSON 파일 읽기 + - exe: json-write-file # JSON 파일 쓰기 + - exe: print-results + +commands: +# 부분 문자열 (startIndex, lastIndex: 0-based, -1은 끝까지) +- command: StringSub + id: string-sub + param: + text: + startIndex: 1 # "v" 제거 + lastIndex: -1 + setValue: <@property.version> + +# 문자열 치환 +- command: StringReplace + id: string-replace + param: + text: + pair: + - from: "v" + to: "" + - from: "-release" + to: "" + setValue: <@property.cleanVersion> + +# 정규식 치환 +- command: StringReplacePattern + id: string-pattern + param: + text: + pattern: "[^0-9.]" # 숫자와 점만 남김 + replace: "" + setValue: <@property.numericVersion> + +# 문자열 내 인덱스 검색 +- command: StringIndex + id: string-index + param: + text: + find: "-" + setValue: <@property.dashIndex> + +# JSON 문자열에서 값 추출 +- command: JsonReader + id: json-read + param: + json: + pair: + - from: status + setValue: <@property.apiStatus> + - from: build.version # 중첩 키 + setValue: <@property.buildVersion> + - from: build.number + setValue: <@property.buildNumber> + +# JSON 파일에서 값 읽기 +- command: JsonReaderFile + id: json-read-file + param: + path: /config/settings.json + pair: + - from: apiKey + setValue: <@property.apiKey> + +# JSON 파일에 값 쓰기 +- command: JsonWriterFile + id: json-write-file + param: + path: /config/settings.json + pair: + - from: version + value: + - from: buildNumber + value: + +- command: Print + id: print-results + param: + message: "버전: , 빌드: , 상태: " diff --git a/assets/yaml/sample/14_shell_process.yaml b/assets/yaml/sample/14_shell_process.yaml new file mode 100644 index 0000000..f655b69 --- /dev/null +++ b/assets/yaml/sample/14_shell_process.yaml @@ -0,0 +1,61 @@ +--- +# [샘플] 셸 실행 + 프로세스 제어 + +property: + workspace: /path/to/project + serverPort: 8080 + +pipeline: + id: main + workflow: + - exe: check-port # 포트 사용 중인지 확인 + - if: + condition-bool: == true + on-true: + - exe: kill-process # 기존 프로세스 종료 + - exe: run-server # 서버 프로세스 실행 + - exe: shell-cmd # 셸 명령 실행 + - exe: shell-script # 셸 스크립트 파일 실행 + +commands: +# 포트 사용 여부 확인 +- command: ProcessPortUse + id: check-port + param: + port: + setPortUse: <@property.portInUse> + +# 특정 포트 프로세스 종료 +- command: ProcessKill + id: kill-process + param: + port: + +# 프로세스 백그라운드 실행 +- command: ProcessRun + id: run-server + param: + command: ./server + args: + - --port + - + setProcessId: <@property.serverPid> + +# 인라인 셸 명령 (여러 줄) +- command: Shell + id: shell-cmd + param: + commands: + - cd + - echo "현재 디렉토리: $(pwd)" + - ls -la + setMessage: <@property.shellOutput> + +# 외부 셸 스크립트 파일 실행 +- command: ShellFile + id: shell-script + param: + path: /scripts/deploy.sh + args: + - + - prod