gitlab项目关联runner
项目 关联 gitlab Runner
2023-09-14 09:00:34 时间
一、背景
在gitlab中新建了一个项目,添加了.gitlab-ci.yml文件,并在文件中写入了测试脚本内容:
stages: - deploy deploy: stage: deploy script: - ping -c 20 127.0.0.1
提交后,stage处于stuck状态,无法运行,检查执行者runner服务,runner服务也存在。
二、分析
考虑是该项目和.gitlab-ci.yml文件脚本的执行者runner之间,还没有建立联系。查询网上资料后,发现需要注册runner。
注册runner参考
https://www.jianshu.com/p/82db7ee85e86
https://blog.csdn.net/u011350541/article/details/80392694
三、方法
1、检查是否有runner服务,并且是否运行。
gitlab-runner status
2、注册runner和项目之间的联系
(1)注册runner前的准备,查询相关url和token
进入项目
projects-》settings-》CI/CD-》Runners (expand) -》Setup a specific Runner manually (记录 url 和 token的值)如下图所示:
(2)命令行注册runner
gitlab-ci-multi-runner register
以下内容的解释:
#引导会让你输入gitlab的url,输入自己的url,例如http://gitlab.example.com/ #引导会让你输入token,去相应的项目下找到token,例如ase12c235qazd32 #引导会让你输入tag,一个项目可能有多个runner,是根据tag来区别runner的,输入若干个就好了,比如web,hook,deploy #引导会让你输入executor,这个是要用什么方式来执行脚本,图方便输入shell就好了。
[root@localhost ~]# gitlab-ci-multi-runner register Running in system-mode. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): http://10.1.2.3:8881/ Please enter the gitlab-ci token for this runner: 5mJH3e3zj_365voC5oLf Please enter the gitlab-ci description for this runner: [localhost.localdomain]: pro01_runner Please enter the gitlab-ci tags for this runner (comma separated): test01,pro01 Whether to run untagged builds [true/false]: [false]: true Whether to lock Runner to current project [true/false]: [false]: false Registering runner... succeeded runner=5mJHse3z Please enter the executor: docker, docker-ssh, parallels, shell, virtualbox, ssh, docker+machine, docker-ssh+machine, kubernetes: shell Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! [root@localhost ~]# gitlab-runner list Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml pro01_runner Executor=shell Token=ccc9f3cb9609d7c52e5a84e8c51fa2 URL=http://10.1.2.3:8881/
(3)在gitlab的web界面可以看到
进入项目
projects-》settings-》CI/CD-》Runners (expand) -》Runners activated for this project 如下图所示:
3、查看脚本的运行
(1)脚本运行时的状态
projects-》CI/CD-》Pipelines -》stages -》 向下箭头 -》 刷新图标(Retry)
(2)脚本运行后的状态
相关文章
- pycharm怎么添加项目_pycharm 其他
- Flink项目实践 | Flink 单机安装部署
- Vue项目中使用TinymMCE富文本
- Thinkphp5学习017-项目案例-多表关联查询
- idea 创建 JavaWeb 项目(主要 idea2022)
- 这个项目真心不要再看了!劝退。。。
- 百矿田阳基地项目启动 广域铭岛再度打造铝行业绿色低碳转型标杆
- 为什么公司需要精益生产项目辅导?
- 分享两个超牛的开源API项目,程序员需要的免费API都在这里了!
- 鲜为人知的 Apache Mesos 项目帮助 Mesosphere 公司得到了千万美元投资
- Linux 基金会发布白皮书,解释如何应对美国对开源项目的出口管制
- OAuth2.1授权服务器Spring Authorization Server正式孵化成功进入Spring项目家族