logo
0
0
WeChat Login

git-commit-list

Fetch commit history list, supports exporting commit list JSON data to a file.

Applicable Events

  • push, branch.create
  • tag_push, tag_deploy.* (tag push / tag deployment; both compare against the previous tag)
  • pull_request, pull_request.target, pull_request.mergeable, pull_request.merged
  • web_trigger_*, api_trigger_* (manual / API triggers; compares the current branch against a target branch)

Parameters

  • toFile: Optional, output commit list to a file, defaults to commit-list.json.
  • tagFormat: Optional, in tag_push / tag_deploy.*, filter the previous tag that matches the specified format and compare it with the current tag. The current tag must match the tagFormat. Defaults to *.
  • branch: Optional, used in web_trigger_* / api_trigger_* to specify the target branch for comparison. If omitted, falls back to the platform-injected default branch (e.g. CNB_DEFAULT_BRANCH); if both are missing, a 未指定对比分支 error is thrown.

Usage in Cloud-Native Build

main:
  push:
  - stages:
    - name: git-commit-list
      image: tencentcom/git-commit-list:latest
      settings:
        # Optional, output commit list to a file
        toFile: commit-list.json
  pull_request:
  - stages:
    - name: git-commit-list
      image: tencentcom/git-commit-list:latest
      settings:
        # Optional, output commit list to a file
        toFile: commit-list.json
$:
  tag_push:
  - stages:
    - name: git-commit-list
      image: tencentcom/git-commit-list:latest
      settings:
        # Optional, filter the previous tag that matches the v* format
        tagFormat: v*
        # Optional, output commit list to a file
        toFile: commit-list.json
  web_trigger_*:
  - stages:
    - name: git-commit-list
      image: tencentcom/git-commit-list:latest
      settings:
        # Optional, target branch to compare against; falls back to the repository's default branch when omitted
        branch: main
        # Optional, output commit list to a file
        toFile: commit-list.json
  api_trigger_*:
  - stages:
    - name: git-commit-list
      image: tencentcom/git-commit-list:latest
      settings:
        # Optional, target branch to compare against; falls back to the repository's default branch when omitted
        branch: main
        # Optional, output commit list to a file
        toFile: commit-list.json

commit-list.json Data Format

[
  {
    "id": "ee0738cc39660baa47e08b6ef3b9f942165d1a0a",
    "short_id": "ee0738cc",
    "author_name": "name",
    "author_email": "name@xxx.com",
    "create_at": "2022-11-24T16:26:48+08:00",
    "message": "fix: Fetch commit history list\n\n#123",
    "title": "fix: Fetch commit history list"
  }
]

Docker

Push Event

docker run --rm \
    -e TZ=Asia/Shanghai \
    # Event name
    -e CNB_EVENT="push" \
    # Commit ID before this commit
    -e CNB_BEFORE_SHA="xxx" \
    # Latest commit ID
    -e CNB_COMMIT="xxx" \
    # Relative path to the file for storing commit list JSON data
    -e PLUGIN_TOFILE="commit-list.json" \
    -v $(pwd):$(pwd) \
    -w $(pwd) \
    tencentcom/git-commit-list:latest

PR Event

docker run --rm \
    -e TZ=Asia/Shanghai \
    # Event name
    -e CNB_EVENT="pull_request" \
    # Source branch name of the MR
    -e CNB_PULL_REQUEST_BRANCH="xxx" \
    # Target branch name of the MR
    -e CNB_BRANCH="master" \
    # Latest commit ID
    -e CNB_COMMIT="xxx" \
    # Relative path to the file for storing commit list JSON data
    -e PLUGIN_TOFILE="commit-list.json" \
    -v $(pwd):$(pwd) \
    -w $(pwd) \
    tencentcom/git-commit-list:latest

Web Trigger / API Trigger Event

docker run --rm \
    -e TZ=Asia/Shanghai \
    # Event name (either web_trigger_* or api_trigger_*)
    -e CNB_EVENT="web_trigger_default" \
    # Current branch name
    -e CNB_BRANCH="feature-x" \
    # Target branch to compare against (optional; falls back to CNB_DEFAULT_BRANCH when omitted)
    -e PLUGIN_BRANCH="main" \
    # Relative path to the file for storing commit list JSON data
    -e PLUGIN_TOFILE="commit-list.json" \
    -v $(pwd):$(pwd) \
    -w $(pwd) \
    tencentcom/git-commit-list:latest

tag_deploy.* / tag_push Event

docker run --rm \
    -e TZ=Asia/Shanghai \
    # Event name (any tag_deploy.* suffix or tag_push)
    -e CNB_EVENT="tag_deploy.prod" \
    # Current tag name
    -e CNB_BRANCH="v2.5.5.5" \
    # Relative path to the file for storing commit list JSON data
    -e PLUGIN_TOFILE="commit-list.json" \
    -v $(pwd):$(pwd) \
    -w $(pwd) \
    tencentcom/git-commit-list:latest

About

git-commit-list

712.00 KiB
0 forks0 stars1 branches2 TagREADMEMIT license
Language
JavaScript90.6%
Shell5.7%
Dockerfile3.7%