一个新的构建将出现在 Build History 面板中。等待它完成(状态图标将变为蓝色表示成功)。
点击构建编号(例如 #1)。
从构建的菜单中点击 Console Output。
你应该会看到输出确认 Jenkins 已成功克隆仓库并执行了你的命令。
Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/git-integration-project
> git rev-parse --resolve-git-dir /var/jenkins_home/workspace/git-integration-project/.git ## timeout=10
...
[git-integration-project] $ /bin/sh -xe /tmp/jenkins123.sh
+ echo Building the project...
Building the project...
+ date
Mon Jan 1 12:01:00 UTC 2024
+ echo Listing files in workspace:
Listing files in workspace:
+ ls -la
total 24
drwxr-xr-x 3 jenkins jenkins 4096 Aug 21 10:33 .
drwxr-xr-x 3 jenkins jenkins 4096 Aug 21 10:33 ..
drwxr-xr-x 8 jenkins jenkins 4096 Aug 21 10:33 .git
-rw-r--r-- 1 jenkins jenkins 32 Aug 21 10:33 README.md
-rw-r--r-- 1 jenkins jenkins 15 Aug 21 10:33 file1.txt
-rw-r--r-- 1 jenkins jenkins 15 Aug 21 10:33 file2.txt
+ echo Build complete!
Build complete!
Finished: SUCCESS
启用 SCM 轮询以实现自动构建
手动运行构建对于测试很有用,但 CI 的真正威力在于自动化。在此步骤中,你将配置 Jenkins,使其在检测到 Git 仓库中的更改时自动启动构建。
Started on Aug 21, 2025, 10:36:00 AM
Using strategy: Default
[poll] Last Built Revision: Revision d22f46ba8c2d4e07d773c5126e9c803933eb5898 (refs/remotes/origin/master)
The recommended git tool is: NONE
No credentials specified
> git --version ## timeout=10
> git --version ## 'git version 2.30.2'
> git ls-remote -h -- https://github.com/labex-labs/git-playground ## timeout=10
Found 3 remote heads on https://github.com/labex-labs/git-playground
[poll] Latest remote head revision on refs/heads/master is: d22f46ba8c2d4e07d773c5126e9c803933eb5898 - already built by 1
Done. Took 0.36 sec
No changes