gitlab-CI/CD運行項目

你用什么用戶啟動gitlab-runner,那么執行的時候,代碼就在該用戶的家目錄。
gitlab-ci觸發以后,gitlab-runner就會把代碼獲取到/home/gitlab-runner/builds,例如我的:
[root@centos3 consumerBanking]# pwd
/home/gitlab-runner/builds/aa766057/0/soa/consumerBanking
[root@centos3 consumerBanking]# ls
pom.xml src
下面是yml的內容:

image.png

創建test文件并提交,觸發gitlab-ci.yml:

image.png

觸發之后就開始做mvn打包動作:

image.png

回到gitlab-runner服務器:

[root@centos3 consumerBanking]# ll
total 16
-rw-rw-r--. 1 gitlab-runner gitlab-runner  775 Sep  2 19:49 pom.xml
drwxrwxr-x. 4 gitlab-runner gitlab-runner 4096 Sep  2 19:49 src
drwxrwxr-x. 7 gitlab-runner gitlab-runner 4096 Sep  2 23:23 target
-rw-rw-r--. 1 gitlab-runner gitlab-runner    4 Sep  2 23:23 test

target就是mvn打的包,并且剛剛創建的test文件也獲取到了。然后這里可以痛過scp將包傳到web服務器的指定目錄。

如果想調用腳本,可以將腳本寫好后,將啊的path添加到/etc/profile 中,例如:

[root@centos3 consumerBanking]# vim /etc/profile
export PATH=/home/gitlab-runner/.local/bin:$PATH
[root@centos3 consumerBanking]# vim /home/gitlab-runner/.local/bin/deploy

#!/bin/bash

echo "fafadfasdhgafgafg"

這樣就相當于命令,只需要這樣就可以調用了:

image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容