参考:http://www.jianshu.com/p/255a484555d9

TeamCity 安装部署(Linux 环境)

  • 在我讲之前,如果你英文还可以,就到官网这里看下:
  • Installation Quick Start
  • 安装环境要求:
    • JDK 1.7 以上,如果你要使用的是 2016 最新的 TeamCity 9.1 的话,JDK 官网推荐的 1.8
  • 安装包下载:https://www.jetbrains.com/teamcity/download/#section=linux-version
  • 开始安装(eg:TeamCity-9.1.6.tar.gz):
    • 解压压缩包(解压速度有点慢):tar zxf TeamCity-9.1.6.tar.gz
    • 解压完的目录结构讲解:https://confluence.jetbrains.com/display/TCD9/TeamCity+Home+Directory
    • 下载的 tar.gz 的本质是已经里面捆绑了一个 Tomcat,所以如果你会 Tomcat 的话,有些东西你可以自己改的。
    • 按我个人习惯,把解压缩的目录放在 usr 目录下:mv TeamCity/ /usr/program/
    • 进入解压目录:cd /usr/program/TeamCity/
    • 启动程序:/usr/program/TeamCity/bin/runAll.sh start
    • 停止程序:/usr/program/TeamCity/bin/runAll.sh stop
    • 启动需要点时间,最好能给它一两分钟吧

首次进入

  • 假设我们已经启动了 TeamCity
  • 访问(TeamCity 默认端口是:8111):http://192.168.1.113:8111/
  • 如果访问不了,请先关闭防火墙:service iptables stop
  • 你也可以选择把端口加入白名单中:
    • sudo iptables -I INPUT -p tcp -m tcp --dport 8111 -j ACCEPT
    • sudo /etc/rc.d/init.d/iptables save
    • sudo service iptables restart
  • 如果你要改变端口,找到下面这个 8111 位置:vim /usr/program/TeamCity/conf/server.xml
<Connector port="8111" ...
  • 在假设你已经可以访问的情况,我们开始进入 TeamCity 的设置向导:
  • TeamCity 向导
  • TeamCity 向导
    • 如上图英文所示,TeamCity 的一些构建历史、用户信息、构建结果等这类数据是需要放在关系型数据库上的,而默认它给我们内置了一个。
    • 如果你要了解更多 TeamCity External Database,你可以看:https://confluence.jetbrains.com/display/TCD9/Setting+up+an+External+Database
    • 首次使用,官网是建议使用默认的:Internal(HSQLDB),这样我们无需在一开始使用的就考虑数据库迁移或安装的问题,我们只要好好感受
      TeamCity 给我们的,等我们决定要使用了,后续再更换数据也是可以的。但是内置的有一个注意点:'TeamCity with the
      native MSSQL external database driver is not compatible with Oracle Java
      6 Update 29, due to a bug in
      Java itself. You can use earlier or later versions of Oracle Java.'
    • 假设我们就选 Internal(HSQLDB) ,则在创建初始化数据库的过程稍微需要点时间,我这边是几分钟。
  • TeamCity 向导
    • 如上图所示,接受下协议
  • TeamCity 向导
    • 如上图所示,我们要创建一个顶级管理员账号,我个人习惯测试的账号是:admin123456
  • TeamCity 向导

项目的构建、管理

- Youshop-Parent,输出是 pom
- Youshop-manage,输出是 pom
- Youshop-pojo,输出 jar
  • 我们现在以 Youshop-pojo 为例,让它自动构建并发布到 Nexus 中,其他项目道理是一样的,这里就不多说。
  • TeamCity 向导
  • 如上图,由于目前只要是公司的项目都应该是在版本控制的,所以这里我们选择:Create project from URL
  • TeamCity 向导
  • 如上图,我们可以看出 TeamCity 也支持 HTTP、SVN、Git 等链接方式。
  • TeamCity 向导
  • 输入你项目托管商的账号密码,我这里用的是 oschina 的。
  • TeamCity 向导
  • 账号、密码验证通过,现在可以给这个项目配置一个项目基本信息。
  • TeamCity 向导
  • 在从版本控制中下载文件和扫描文件
  • TeamCity 向导
  • TeamCity 自动扫描到我是用 Maven 构建的项目,所以把 POM 文件找出来了,如果你一个项目有多种构建方式,有对应的配置文件的话,这里都会显示出来的。
  • 我们勾选 Maven 前面的复选框,点击:Use Selected
  • TeamCity 向导
  • 由于我们的目标是构建完自动发布到 Nexus,所以我们的 Maven Goals 应该是:clean install deploy,这里我们应该点击:Edit,进行编辑。
  • 如果你不懂 Maven Goals,那你需要学习下,这个很重要。
  • TeamCity 向导
    • 如上图,这台服务器必须装有 Maven、JDK
    • 如上图,Goals 我们的目标是 clean install deploy
    • 如上图,Maven Home 我建议是自己自定义路径,这样肯定不会有问题。所以你服务器上的 Maven 安装路径是什么你就在这里填写上去。Maven 目前支持的最高版本是:3.2.5
    • 如上图,Java Parameters 我建议也是自己自定义路径,别选择其他选项。
  • TeamCity 向导
    • 如上图,点击 run,开始手动构建该项目
  • TeamCity 向导
    • 如上图,我们看到简略的构建日志
  • TeamCity 向导
  • TeamCity 向导
    • 如上 2 张图,我们看到详细的构建内容
  • TeamCity 向导
    • 如上图,当我们版本控制中有提交的时候,TeamCity 会识别到记录
  • TeamCity 向导
    • 如上图,我们可以看到提交的 Commit Message 信息。
    • 如上图,右边红圈的三个按钮是用来处理这次提交的,常用的是第一次按钮,点击对此次版本进行构建
  • TeamCity 向导
    • 如上图,如果你要看所有的提交记录,可以在 Change Log 看到并且指定版本构建
  • TeamCity 向导
    • 如上图,如果在你不想要这个项目的时候可以进行删除
  • TeamCity 向导
    • 如上图,因为 Goals 里面有 deploy 命令,所以构建完成会发布到 Nexus 中,这样团队的人就可以用到最新的代码了
  • TeamCity 向导
    • 如上 gif 图演示,项目常去的几个配置地方就是这样些了

配置自动构建触发行为

  • 官网提供的触发行为有:https://confluence.jetbrains.com/display/TCD9/Configuring+Build+Triggers
  • 下面我们举例说常见的:VCS TriggerSchedule Trigger
  • TeamCity 向导
    • 如上图,点击 Add new trigger 添加触发器
  • TeamCity 向导
    • 如上图,常见的触发器就这些了
  • TeamCity 向导
    • 如上图,配置好 VCS Trigger 效果是,当我们有代码提交的时候,TeamCity 检查到新版本之后自动构建,这个最常用

参考:http://blog.csdn.net/johnstrive/article/details/49894195

STEP1下载安装

目前免费版是2.x,所以下载个免费版
https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.13.0-01-bundle.tar.gz

[root@localhost ~]# tar -zxvf nexus-2.13.0-01-bundle.tar.gz
[root@localhost download]# ll
total 70780
drwxr-xr-x. 8 1001 1001 4096 Apr 12 16:11 nexus-2.13.0-01 #nexus 服务
-rw-r--r--. 1 root root 72466664 Jun 23 08:28 nexus-2.13.0-01-bundle.tar.gz
drwxr-xr-x. 3 1001 1001 4096 Apr 12 16:21 sonatype-work #私有库目录

STEP2 配置

nexus.properties配置文件

[root@localhost conf]# pwd
/root/download/nexus-2.13.0-01/conf
[root@localhost conf]# vim nexus.properties
# Jetty section
application-port=8081 #默认访问端口,可以修改为自己需要的端口,并加入到iptables链
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

nexus执行文件

[root@localhost conf]# vi /root/download/nexus-2.13.0-01/bin/nexus
#RUN_AS_USER=
改为:
RUN_AS_USER=root

防火墙中打开 8081 端口

# vi /etc/sysconfig/iptables
添加:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT 保存后重启防火墙
# service iptables restart

STEP3 启动 nexus

[root@localhost conf]# /root/download/nexus-2.13.0-01/bin/nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.

关于如何使用nexus

网上资料很多,参考几篇就搞定了。
http://www.cnblogs.com/luotaoyeah/p/3791966.html
http://blog.csdn.net/ichsonx/article/details/14642897

其他关键配置项

切换中央仓库为阿里云仓库,修复索引

加入central到public仓库地址,这样才能正常下载到依赖

项目配置

Maven配置

首先需要配置是的maven的setting.xml文件,我直接全部放上来,具体看注释

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--设置自己的maven本地仓库-->
<localRepository>/Users/jm/Documents/work/mrepository</localRepository> <pluginGroups/>
<proxies/>
<servers>
<server>
<id>nexus-rs</id> <!--这个ID要与下面的repository中的ID一致-->
<username>deployment</username> <!--nexus中配置的用户名密码-->
<password>xiaoshoujia123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>deployment</username>
<password>xiaoshoujia123</password>
</server>
</servers>
<mirrors><!--从nexus下载依赖地址-->
<mirror>
<id>nexus-public</id>
<mirrorOf>central</mirrorOf>
<name>central repository</name>
<url>http://192.168.199.146:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors> <profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus-rs</id> <!--正式仓库id-->
<!--name随便-->
<name>Nexus Release Snapshot Repository</name>
<!--地址是nexus中repository(Releases/Snapshots)中对应的地址-->
<url>http://192.168.199.146:8081/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository> <repository>
<id>nexus-snapshots</id>
<url>http://192.168.199.146:8081/nexus/content/repositories/snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository> </repositories>
<pluginRepositories> <!--插件仓库地址,各节点的含义和上面是一样的-->
<pluginRepository>
<id>nexus-rs</id>
<name>Nexus Release Snapshot Repository</name>
<url>http://192.168.199.146:8081/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>nexus-snapshots</id>
<url>http://192.168.199.146:8081/nexus/content/repositories/snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile> <!--激活配置-->
<activeProfiles>
<activeProfile>nexus</activeProfile> <!--profile下的id-->
</activeProfiles> </settings>
  • 64
  • 65

pom.xml配置

根节点project中增加

        <distributionManagement>
<!-- 两个ID必须与 setting.xml中的<server><id>nexus-rs</id></server>保持一致-->
<repository>
<id>nexus-rs</id>
<name>Nexus Release Repository</name>
<url>http://192.168.199.146:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.199.146:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

TeamCity 和 Nexus 的使用的更多相关文章

  1. 持续集成:TeamCity 的安装和使用

    TeamCity 本文初衷 让大家了解持续集成(CI),以及入门了解 JetBrains 家的 TeamCity 的一些简单实用. TeamCity 的一些复杂使用我暂时也不会,一样也是要看文档的,所 ...

  2. Nexus(一)环境搭建

    昨天,成功搭建了自己的 Maven 环境(详见:Maven(一)环境搭建),今天就来研究和探讨下 Nexus 的搭建! 使用背景: 安装环境:Windows 10 -64位 JDK版本:1.7 Mav ...

  3. nexus 社区版3.0.2部署、访问

    下载nexus社区办(oss): https://www.sonatype.com/download-oss-sonatype 目前最新版本  nexus-3.0.2-02-win64.zip nex ...

  4. 使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(二)

    前言     上一篇随笔Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(一)介绍maven和nexus的环境搭建,以及如何使用maven和nexus统一管理库 ...

  5. 使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(一)

    前言     但凡一个略有规模的项目都需要一个持续集成环境的支撑,为什么需要持续集成环境,我们来看一个例子.假如一个项目,由A.B两位程序员来协作开发,A负责前端模块,B负责后端模块,前端依赖后端.A ...

  6. Failure to find xxx in xxx was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced @ xxx

    问题: 在linux服务器上使用maven编译war时报错: 16:41:35 [FATAL] Non-resolvable parent POM for ***: Failure to find * ...

  7. TeamCity : 自动触发 Build

    创建了 build 的配置以后,您既可以手动点击 "Run" 按钮来触发一次 build 过程,也可以通过 Triggers 配置实现自动触发 build 过程.一个 trigge ...

  8. TeamCity : .NET Core 插件

    笔者在<TeamCity : 配置 Build 过程>一文中提到 "TeamCity 内置支持几乎所有的 build 类型".在当今这个软件语言和各种框架飞速发展的时代 ...

  9. TeamCity : 配置 Build 过程

    Build 过程往往是比较复杂的,因此 TeamCtiy 通过 build 步骤的方式让您可以实现不同的应用场景.您可以在每个 build 步骤中只做一件事情,然后把一系列的 build 步骤组织起来 ...

随机推荐

  1. EF 更新 删除

    为了避免先查询后更新或删除的问题 可以使用如下语句 Entities db = new Entities(); Orders o = new Orders(); o.id = 6; o.name = ...

  2. MT【34】正余弦的正整数幂次快速表示成正余弦的线性组合

    问题:如何快速把$cos^4xsin^3x$表示成正弦,余弦的线性组合? 分析:利用牛顿二项式展开以下表达式: 再利用欧拉公式$e^{i\theta}=cos\theta+isin\theta$ 比如 ...

  3. 【LightOJ 1136】Division by 3(简单数学)

    BUPT2017 wintertraining(16) #5 C HDU - 1021 题意 1, 12, 123, 1234, ..., 12345678910, ... 问第a到第b个数(incl ...

  4. 洛谷 P4074 [WC2013]糖果公园 解题报告

    P4074 [WC2013]糖果公园 糖果公园 树上待修莫队 注意一个思想,dfn序处理链的方法,必须可以根据类似异或的东西,然后根据lca分两种情况讨论 注意细节 Code: #include &l ...

  5. luogu2827 [NOIp2016]蚯蚓 (模拟)

    可以直观地想到用优先队列来做,但数据范围是O(n)的 然后我们发现,因为我们每次挑出来的蚯蚓是单调的,所以把每个切成两段后,那两段也是对应单调的 也就是说,算上最一开始的蚯蚓,我们一共维护三个队列,三 ...

  6. C# 面向对象零碎知识点

    obgect: 所有数据类型都是obgect类型: 万能类型 var :原来的变量不变,替换成var: 动态类型 dynamic :类似object,遍历需要转: is  as: 类型转换运算符: ( ...

  7. NOIP2016 巨凉无比的感言

    打一场比赛检验自己的水平. D1: 我日苟了,考得跟屎一样. 第一题不说了,奇水无比(跟17年相比的话). 第二题,大名鼎鼎啊... 虽然以前看过题解但是实际做起来只会25分暴力...至少比半年前好多 ...

  8. java.lang.OutOfMemoryError及解决方案

    主要有3种比较常见的OutOfMemory Error: java.lang.OutOfMemoryError: Java heap space java.lang.OutOfMemoryError: ...

  9. 窗体焦点监听事件WindowFocusListener

      public class Demo extends JFrame { JLabel label;//定义变量,以便在自定义方法类中调用 public Demo() { setBounds(100, ...

  10. Kubernetes Pv & Pvc

    Kubernetes PV & pvc 介绍 PersistentVolume(pv)和PersistentVolumeClaim(pvc)是k8s提供的两种API资源,用于抽象存储细节.管理 ...