gitlab cicd自动打包发布到私有仓库

您所在的位置:网站首页 gitlab查看仓库地址 gitlab cicd自动打包发布到私有仓库

gitlab cicd自动打包发布到私有仓库

2023-03-24 21:54| 来源: 网络整理| 查看: 265

首先安装gitlab runner

 

查看安装说明

sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 # Give it permission to execute sudo chmod +x /usr/local/bin/gitlab-runner # Create a GitLab Runner user sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash # Install and run as a service sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner sudo gitlab-runner start

注册runner

sudo gitlab-runner register --url $GITLABURL --registration-token $REGISTRATION_TOKEN

[root@gitlab ~]# gitlab-runner register --url http://192.168.55.11/ --registration-token GR1348941iEsdsdq12f:%wea Runtime platform arch=amd64 os=linux pid=221844 revision=bd40e3da version=14.9.1 Running in system-mode. Enter the GitLab instance URL (for example, https://gitlab.com/): [http://192.168.55.11/]: Enter the registration token: [GR1348941iEsdsdq12f:%wea]: Enter a description for the runner: [gitlab]: k8s #任意输入 Enter tags for the runner (comma-separated): k8s-git #任意输入 Enter optional maintenance note for the runner: Registering runner... succeeded runner=GR134894 Enter an executor: kubernetes, custom, parallels, shell, ssh, virtualbox, docker+machine, docker-ssh+machine, docker, docker-ssh: shell #此处可根据自己情况进行选择docker Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

注册完成后可看到新创建的Runner

 完成runner创建后可进行cicd编辑

在使用shell模式时,需要在gitlab服务器上安装git及maven,在代码库的pom.xml上添加私有仓库地址,需要和maven下settings.xml相对应

maven-releases Releases http://192.168.55.22/repository/maven-releases/ maven-snapshots Snapshot http://192.168.55.22/repository/maven-snapshots/

settingx.xml配置

maven-releases * http://192.168.55.22/repository/maven-public/ maven-snapshots * http://192.168.55.22/repository/maven-public/ maven-releases nexususer Ne3#k4%l maven-snapshots nexususer Ne3#k4%l nexus maven-releases http://192.168.55.22/repository/maven-releases/ true true maven-snapshots http://192.168.55.22/repository/maven-snapshots/ true true maven-releases http://192.168.55.22/repository/maven-releases/ true true maven-snapshots http://192.168.55.22/repository/maven-snapshots/ true true

gitlab-ci.yml配置内容,仅master分支触发

stages: - build job_build: stage: build script: - echo "start mvn build!!!" - echo $CI_COMMIT_TAG - mvn versions:set -DnewVersion=$CI_COMMIT_TAG - mvn clean deploy only: - master tags: - mvn #此处为Runner的tag,可用于指定Runner


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3