前置条件:html
.gitlab-ci.yml
文件,用于定义工做内容;在 GitLab 中,Runner 是运行持续集成工做内容的代理。git
查看可用的 GitLab Runner:Settings > CI/CD > Runnersdocker
有绿色圆圈的 Runner 即为处于激活状态。工具
install GitLab Runner gitlab
.gitlab-ci.yml
文件.gitlab-ci.yml
文件用于配置具体的工做内容。代理
在文件中能够定义如下内容:code
建立步骤:htm
.gitlab-ci.yml
,填入示例代码;build-job: stage: build script: - echo "Hello, $GITLAB_USER_LOGIN!" test-job1: stage: test script: - echo "This job tests something" test-job2: stage: test script: - echo "This job tests something, but takes more time than test-job1." - echo "After the echo commands complete, it runs the sleep command for 20 seconds" - echo "which simulates a test that runs 20 seconds longer than test-job1" - sleep 20 deploy-prod: stage: deploy script: - echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
$GITLAB_USER_LOGIN
和$CI_COMMIT_BRANCH
均为运行时变量。
.gitlab-ci.yml
文件提示在提交修改后,一个 pipeline 将会被启动。继承
查看 pipeline :
若是工做状态为 stuck
,请检查项目中是否有可用的 Runner 。