gitlab-runner (一)
gitlab-runner用来跑 job, 每个 job 都是独立运行的, 每个 job 名称可以随意命名, 但是 script 是必填项, before_script 会在每个 job 执行之前执行, 不是必填项。
This is the simplest possible configuration that will work for most Ruby applications:
- Define two jobs
rspec
andrubocop
(the names are arbitrary) with different commands to be executed. - Before every job, the commands defined by
before_script
are executed.
The .gitlab-ci.yml
file defines sets of jobs with constraints of how and when they should be run. The jobs are defined as top-level elements with a name (in our case rspec
and rubocop
) and always have to contain the script
keyword. Jobs are used to create jobs, which are then picked by Runners and executed within the environment of the Runner.
What is important is that each job is run independently from each other.
maven项目构建:(variables, cache 记着写,这样可以加快构建速度)
gitlab-ci.yml 文件的编写说明:
https://docs.gitlab.com/ee/ci/yaml/README.html
2.一个job 包含的基本元素:
stage
script : 最重要!这下面的脚本会在runner安装的服务器上执行;默认在runner 的工作目录下, 且runner工作目录下默认有打标签的最新分支的代码
tag : runner tag
only:
except:
示例:只在打tags 的branch 上运行, 只在 branch 上打 tags, 不要在 master 上打 tag ,因为 master 也算一个分支
only:
- tags
参考:https://www.jianshu.com/p/3c0cbb6c2936
https://segmentfault.com/a/1190000011890710