亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

『中級篇』docker之CI/CD持續集成—真實JAVA-Maven項目的CI演示(73)

標簽:
Docker

copy到gitlab上

  • new project


    webp

  • Git repository URL

https://github.com/limingios/gitlabci-maven

webp

  • 点击create project

webp

webp

runner管理新的gitlabci-maven

webp

maven的环境

 sudo gitlab-ci-multi-runner register

webp

新建github-ci 文件

webp

# These are the default stages. You don't need to explicitly define them. But you could define any stages you need.stages:
  - build
  - test
  - deploy# This is the name of the job. You can choose it freely.maven_build:  # A job is always executed within a stage. If no stage is set, it defaults to 'test'
  stage: test
  # Since we require Maven for this job, we can restrict the job to runners with a certain tag. Of course, we need to configure a runner with the tag maven with a maven installation
  tags:
    - maven  # Here you can execute arbitrate terminal commands.
  # If any of the commands returns a non zero exit code the job fails
  script:
    - echo "Building project with maven"
    - mvn verify

开始CI操作

修改.gitlab-ci.yml 就开启了自动构建模式。

  • 报错了。 跟python当初构建的时候一样。

Running with gitlab-ci-multi-runner 9.5.1 (96b34cc)
  on maven (e6c8a28d)
Using Docker executor with image maven:latest ...
Using docker image sha256:c4ef2f017e30bbabddf847a3f458985e55ccc24a2be7dbdf72dc032e7bece3e5 for predefined container...
Pulling docker image maven:latest ...
Using docker image maven:latest ID=sha256:1361ae58b0a463172267a0622430ad5f4f8108c4d4b7b1ae7d552e367cf92413 for build container...
Running on runner-e6c8a28d-project-3-concurrent-0 via gitlab-ci...
Cloning repository...
Cloning into '/builds/root/gitlabci-maven'...
fatal: unable to access 'http://gitlab-ci-token:[email protected]/root/gitlabci-maven.git/': Couldn't resolve host 'gitlab.example.com'
ERROR: Job failed: exit code 1

webp

Runner启动的docker容器里无法访问到gitlab.example.com这个地址(能访问到才怪)。这一般是由于我们的测试环境没有使用域名导致的,gitlab论坛里也不少人讨论这个问题,如果你是在部署正式的gitlab环境,那你自然会有一个域名来使用。不过我这里只是搭建测试环境,所以我使用了一种投机的方法:

修改Runner的/etc/gitlab-runner/config.toml文件,在其中的[runner.docker]下增加:

sudo vi /etc/gitlab-runner/config.toml

webp

webp

成功了 重新Retry

webp

6666 美滋滋,当初怼了个python现在java遇到这个问题知道咋解决了。

webp

用的不是阿里云,可能比较慢,不过是演示,之后想想办法直接在脚本里面配置下私有库的地址。

webp

PS:这次主要给大家简单的介绍下CI,还没设计到CD。下次吧!



作者:IT人故事会
链接:https://www.jianshu.com/p/08f55f17a237


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消