李明
|
创建虚拟机
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version ">= 1.6.0" boxes = [ { :name => "gitlab-ci", :mem => "4096", :cpu => "2" } ] Vagrant.configure(2) do |config| config.vm.box = "centos/7" boxes.each do |opts| config.vm.define opts[:name] do |config| config.vm.hostname = opts[:name] config.vm.provider "vmware_fusion" do |v| v.vmx["memsize"] = opts[:mem] v.vmx["numvcpus"] = opts[:cpu] end config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", opts[:mem]] v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] end config.vm.network :private_network, type: "dhcp" end end config.vm.provision "shell", privileged: true, path: "./setup.sh" end
#/bin/shsudo yum install -y yum upgrade sudo yum install -y net-tools sudo yum install -y curl policycoreutils openssh-server openssh-clients sudo systemctl enable sshd sudo systemctl start sshd sudo yum install -y postfix sudo systemctl enable postfix sudo systemctl start postfix sudo firewall-cmd --permanent --add-service=http sudo systemctl reload firewalld sudo curl -sSL https://get.docker.com/ | sh 执行命令创建#源码No.11的gitlab-ci目录 vagrant up
更改安装源
sudo touch /etc/yum.repos.d/gitlab-ci-multi-runner.repo sudo vi /etc/yum.repos.d/gitlab-ci-multi-runner.repo 将以下内容写入文件 [gitlab-ci-multi-runner] name=gitlab-ci-multi-runner baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ci-multi-runner/yum/el7 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key 执行 sudo yum makecache sudo yum install gitlab-ci-multi-runner
sudo gitlab-ci-multi-runner status
sudo usermod -aG docker gitlab-runner sudo service docker restart sudo gitlab-ci-multi-runner restart
gitlab-ci注册
http://172.28.128.3/
i_qDxLL_yQTzMuSR1-6J
#自己起个名字方便区别test1
#自己起个标签方便区别test1
#直接回车
#直接回车
shell
gitlab-ci如何使用
stages: - test - build - deploy job1: stage: test tags: - test1 script: - echo "个人网站:idig8.com" - echo "个人公众号:编程坑太多" - echo "--------job1----------"job2: stage: build tags: - test1 script: - echo "个人网站:idig8.com" - echo "个人公众号:编程坑太多" - echo "--------job2----------"job3: stage: deploy tags: - test1 script: - echo "个人网站:idig8.com" - echo "个人公众号:编程坑太多" - echo "--------job3----------"
#原来是域名的问题,开始修改。Running with gitlab-ci-multi-runner 9.5.1 (96b34cc) on gitlab-ci (4d12d67f) Using Shell executor...Running on gitlab-ci... Cloning repository...Cloning into '/home/gitlab-runner/builds/4d12d67f/0/root/test1'... fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.example.com/root/test1.git/': Could not resolve host: gitlab.example.com; Unknown errorERROR: Job failed: exit status 1
sudo vi /etc/hosts # 添加 172.28.128.3 gitlab.example.com 重新ci
PS:整个这个功能是否给你一个很大的想象空间,任何的软件的项目,可以通过ci-Pipelines方式,来定义自己的Pipelines,在测试,部署。很大很的发挥空间。都可以通过自定yml文件来实现。 |
2018-10-27 00:42:46