Trigger a source code pull with a push event from the git webhook. And then execute the commands.
3.9K
Git Job is a professional webhook-based automation tool that triggers source code pulls and executes custom commands when receiving Git webhook events. Built on funnyzak/java-nodejs-python-go-etc-docker, it provides a complete CI/CD automation solution with build capabilities, notifications, and multi-platform support.
The image is available for multiple architectures, including linux/amd64, linux/arm64, and linux/arm/v7.
Docker Pull Command: docker pull funnyzak/git-job:latest
China Mirror: docker pull registry.cn-beijing.aliyuncs.com/funnyzak/git-job:latest
The container includes a built-in Nginx web server that listens for webhook events:
/hooks/git-webhook?token=HOOK_TOKENpush eventsExample URLs:
http://hostname:80/hooks/git-webhook?token=HOOK_TOKENhttp://hostname:9000/hooks/git-webhook?token=HOOK_TOKEN⚠️ Important Version Notice: The current version is not compatible with versions prior to 2.0.0. If you need to use the legacy version, please use tag 1.1.0:
docker pull funnyzak/git-job:1.1.0
The following environment variables are used to configure the container:
The following environment variables are required for basic operation:
GIT_USER_EMAIL - The email of the git committer. Required.GIT_REPO_URL - The remote URL of the git repository. Required. Example: [email protected]:funnyzak/vp-starter.git.HOOK_TOKEN - The authentication token for the webhook. Required.Commonly used configuration options:
USE_HOOK - Enable or disable the webhook listener. Default: true.GIT_USER_NAME - The username of the git committer. Optional.GIT_BRANCH - The branch to pull from the repository. Default: the repository's main branch.CODE_DIR - The directory where git repository will be cloned. Default: /app/code.TARGET_DIR - The directory for build outputs and deployment. Default: /app/target.Configure the automated build process:
INSTALL_DEPS_COMMAND - Command to install dependencies after pulling code. Example: npm install, pip install -r requirements.txt.BUILD_COMMAND - Command to build the project after installing dependencies. Example: npm run build, mvn package.BUILD_OUTPUT_DIR - Build output directory relative to CODE_DIR. Example: dist, build, target.AFTER_BUILD_COMMANDS - Commands to execute after successful build. Example: npm run deploy, docker-compose up -d.Execute custom commands at different stages:
STARTUP_COMMANDS - Commands executed when container starts.BEFORE_PULL_COMMANDS - Commands executed before pulling code from repository.AFTER_PULL_COMMANDS - Commands executed after pulling code from repository.Configure notification system using Pushoo:
SERVER_NAME - Server name displayed in notification messages. Optional.PUSHOO_PUSH_PLATFORMS - Notification platforms, separated by commas. Example: dingtalk,bark,wechat.PUSHOO_PUSH_TOKENS - Authentication tokens for notification platforms, separated by commas.PUSHOO_PUSH_OPTIONS - JSON object with platform-specific options. Example: {"dingtalk":{"atMobiles":["13800000000"]},"bark":{"sound":"tink"}}.PUSH_MESSAGE_HEAD - Custom header text for notification messages.PUSH_MESSAGE_FOOT - Custom footer text for notification messages.For more details about Pushoo configuration, please refer to pushoo-cli.
Configure automatic upload to AliCloud Object Storage Service:
ALIYUN_OSS_ENDPOINT - AliCloud OSS endpoint. Example: oss-cn-beijing-internal.aliyuncs.com.ALIYUN_OSS_AK_ID - AliCloud Access Key ID.ALIYUN_OSS_AK_SID - AliCloud Access Key Secret.The following volume mounts are available for persistent storage and custom scripts:
/app/code - Git repository working directory. Must match CODE_DIR./app/target - Build output directory. Must match TARGET_DIR./root/.ssh - SSH keys for Git authentication./app/scripts - Main container scripts (contains hook.sh, utils.sh, entrypoint.sh)./custom_scripts/on_startup - Custom scripts executed at container startup./custom_scripts/before_pull - Custom scripts executed before code pull./custom_scripts/after_pull - Custom scripts executed after code pull.Basic deployment with minimal configuration:
docker run -d \
--name git-job \
--restart on-failure:5 \
--privileged=true \
-e TZ=Asia/Shanghai \
-e LANG=C.UTF-8 \
-e USE_HOOK=true \
-e GIT_USER_NAME=Leon \
-e [email protected] \
-e [email protected]:funnyzak/git-job.git \
-e HOOK_TOKEN=your-webhook-token \
-p 8080:80 \
-v ./ssh:/root/.ssh \
funnyzak/git-job:latest
Full-featured setup with notifications, build pipeline, and custom scripts:
version: '3.8'
services:
git-job:
image: funnyzak/git-job:latest
container_name: git-job
privileged: false
working_dir: /app/code
tty: true
restart: unless-stopped
environment:
# Basic Configuration
- TZ=Asia/Shanghai
- LANG=C.UTF-8
- USE_HOOK=true
- GIT_USER_NAME=Leon
- [email protected]
- HOOK_TOKEN=${HOOK_TOKEN}
- [email protected]:your-org/your-repo.git
- GIT_BRANCH=main
# Custom Commands
- STARTUP_COMMANDS=echo "Container started at $$(date)"
- BEFORE_PULL_COMMANDS=echo "Starting code pull..."
- AFTER_PULL_COMMANDS=echo "Code pull completed"
# Build Pipeline
- INSTALL_DEPS_COMMAND=npm install
- BUILD_COMMAND=npm run build
- BUILD_OUTPUT_DIR=dist
- AFTER_BUILD_COMMANDS=echo "Build completed successfully"
# Notifications
- SERVER_NAME=Production CI/CD
- PUSHOO_PUSH_PLATFORMS=dingtalk,bark
- PUSHOO_PUSH_TOKENS=${DINGTALK_TOKEN}:${BARK_TOKEN}
- PUSHOO_PUSH_OPTIONS={"dingtalk":{"atMobiles":["13800000000"]},"bark":{"sound":"tink"}}
- PUSH_MESSAGE_HEAD=🚀 Deployment Update
- PUSH_MESSAGE_FOOT=## View Details\n* [Dashboard](https://your-dashboard.com)
# AliCloud OSS (Optional)
- ALIYUN_OSS_ENDPOINT=oss-cn-beijing.aliyuncs.com
- ALIYUN_OSS_AK_ID=${OSS_ACCESS_KEY}
- ALIYUN_OSS_AK_SID=${OSS_SECRET_KEY}
# Directory Configuration
- CODE_DIR=/app/code
- TARGET_DIR=/app/target
ports:
- "8080:80"
- "9000:9000"
volumes:
- ./code:/app/code
- ./target:/app/target
- ./ssh:/root/.ssh:ro
- ./scripts/custom_startup.sh:/custom_scripts/on_startup/01-startup.sh
- ./scripts/custom_build.sh:/custom_scripts/after_pull/02-build.sh
Minimal setup for basic Git operations:
version: '3.8'
services:
git-job:
image: funnyzak/git-job:latest
container_name: git-job
restart: unless-stopped
environment:
- GIT_USER_NAME=Leon
- [email protected]
- HOOK_TOKEN=${HOOK_TOKEN}
- [email protected]:your-org/your-repo.git
- GIT_BRANCH=main
- AFTER_PULL_COMMANDS=npm install && npm run build
ports:
- "8080:80"
volumes:
- ./code:/app/code
- ./ssh:/root/.ssh:ro
Generate SSH keys and mount them for secure Git operations:
# Generate SSH key pair
ssh-keygen -t rsa -b 4096 -C "[email protected]" -N "" -f ./ssh/id_rsa
# Add the public key to your Git repository's deploy keys
# Then mount the SSH directory
docker run -d \
--name git-job \
-e [email protected] \
-e [email protected]:your-org/your-repo.git \
-e HOOK_TOKEN=your-token \
-v ./ssh:/root/.ssh:ro \
-p 8080:80 \
funnyzak/git-job:latest
The container provides comprehensive logging for all operations:
View logs in real-time:
# View all container logs
docker logs -f git-job
# View recent logs
docker logs --tail 100 git-job
# Filter logs by pattern
docker logs git-job | grep "webhook\|build\|error"
Monitor container health and webhook functionality:
# Check container status
docker ps
# Test webhook endpoint
curl "http://localhost:8080/hooks/git-webhook?token=your-token" \
-X POST \
-H "Content-Type: application/json" \
-d '{"ref":"refs/heads/main"}'
For secure Git operations using SSH keys:
Generate SSH Keys:
ssh-keygen -t rsa -b 4096 -C "[email protected]" -N "" -f ./ssh/id_rsa
Mount SSH Directory:
volumes:
- ./ssh:/root/.ssh:ro # Read-only for security
Add Public Key to Repository:
./ssh/id_rsa.pub as a deploy key in your Git repositoryHOOK_TOKEN valuesEnable verbose logging for troubleshooting:
environment:
- VERBOSE=true # Enable detailed debug output
If you're upgrading from version 1.1.0 or earlier, note the following changes:
/hooks/git-webhookFor legacy compatibility, continue using tag 1.1.0:
docker pull funnyzak/git-job:1.1.0
This project is licensed under the MIT License - see the repository for details.
Content type
Image
Digest
sha256:c4e7996f6…
Size
597.9 MB
Last updated
7 months ago
docker pull funnyzak/git-job