参考: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. webapi返回泛型给easyui

    由于之前遇到的easyui调用webapi的问题. 参见 :http://blog.csdn.net/hanjun0612/article/details/51144991 所以就考虑,封装一个泛型用 ...

  2. debian 系统安装配置apache

    安装sshapt-get install ssh-server  (安装失败请插入镜像)service ssh start Apache 服务安装apt-get install apache2 apa ...

  3. mysql 计算两个日期之间的工作日天数

    创建透视表t500 建表 CREATE TABLE `t500` ( `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE ...

  4. #define用法之一

    [问题由来] 多文件工程中,A文件要使用B文件的func1函数,只要在A文件中include “B.h”即可: 但A文件中使用的是func2函数,它与func1函数功能一样,只是名字不同而已,即fun ...

  5. IPython Notebook 运行python Spark程序

    1.安装pip 因为centos7.0自带的python系统是2.7.5,并没有安装pip,需要先安装pip $ wget https://bootstrap.pypa.io/get-pip.py $ ...

  6. MQTT——取消订阅报文和断开连接报文

    笔者已经把连接报文,订阅报文,发布报文都讲解了完了.而接下来就是取消订阅报文和断开连接报文.和其他的报文比较的话,他们显示非常简单.甚至笔者觉得可以不必要拿出来讲.只要看一下MQTT文档就没有什么不清 ...

  7. img标签浏览器缓存图片问题

    问题:项目中用的img标签及其src属性,但是发现浏览器会缓存图片,这样每次如果修改了图片,再重新打开预览发现图片还是原来的. 原因:因为src后面的请求路径不变,所以浏览器就认为是同一个图片,就不会 ...

  8. 集合类(常见的集合类:Collection、List、Set、ArrayList、linkedList、Vector、HashSet、TreeSet)

    一.集合类 定义:一种为了对多个对象进行操作而进行存储的方式. 1.与数组的区别: 数组:可以存储对象,也可以存储基本数据类型,但是一次只能存储一种类型,数组长度固定. 集合:只能存储对象,长度可变, ...

  9. Codeforces Round #510 (Div. 2)(C)

    传送门:Problem C https://www.cnblogs.com/violet-acmer/p/9682082.html 题意: 给你n个数,定义有两种操作 ① 1 i j : (i != ...

  10. (大数)Computer Transformation hdu1041

    Computer Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/ ...