上次主要说了在githubCI的服务器,并且也演示了github的runner执行CICD,这次通过真实的JAVA-Maven项目来演示下CICD。项目通过gitlab和gitlabCI进行CICD。
源码地址:https://github.com/limingios/gitlabci-maven
随便找一个开源的JAVA-Maven的在github项目。添加到gitlab上。
copy到gitlab上
- new project
-
Git repository URL
>https://github.com/limingios/gitlabci-maven
- 点击create project
runner管理新的gitlabci-maven
maven的环境
sudo gitlab-ci-multi-runner register
新建github-ci 文件
# 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:xxxxxxxxxxxxxxxxxxxx@gitlab.example.com/root/gitlabci-maven.git/': Couldn't resolve host 'gitlab.example.com' ERROR: Job failed: exit code 1
Runner启动的 docker 容器里无法访问到 gitlab.example.com 这个地址(能访问到才怪)。这一般是由于我们的测试环境没有使用域名导致的, gitlab论坛 里也不少人讨论这个问题,如果你是在部署正式的gitlab环境,那你自然会有一个域名来使用。不过我这里只是搭建测试环境,所以我使用了一种投机的方法:
修改Runner的 /etc/gitlab-runner/config.toml 文件,在其中的 [runner.docker] 下增加:
sudo vi /etc/gitlab-runner/config.toml
成功了 重新Retry
6666 美滋滋,当初怼了个python现在 java 遇到这个问题知道咋解决了。
>>原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
>>原文链接地址:
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 『中级篇』docker之CI/CD持续集成-CD演示(74)
- 『中级篇』docker之CI/CD持续集成—真实Python项目的CI演示(72)
- 堆排序动画演示,Python代码演示,看不懂你砍我!
- GraphQL案例演示
- Kubernetes身份验证机制演示
- 中心极限定理的Matlab演示
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Coding the Matrix
Philip N. Klein / Newtonian Press / 2013-7-26 / $35.00
An engaging introduction to vectors and matrices and the algorithms that operate on them, intended for the student who knows how to program. Mathematical concepts and computational problems are motiva......一起来看看 《Coding the Matrix》 这本书的介绍吧!