1.安装jdk。jenkins 是一个java web程序。所以必然需要jdk。
yum install java 或者 yum install java-1.8.0-openjdk
2.下载jenkins安装包
# wget -P /opt https://pkg.jenkins.io/redhat-stable/jenkins-2.7.4-1.1.noarch.rpm
下载安装包到/opt目录
安装包下载页面:https://jenkins.io/download/
centos安装包页面:https://pkg.jenkins.io/redhat-stable/
3.安装jenkins
# cd /opt
# rpm -ivh jenkins-2.7.4-1.1.noarch.rpm
4.启动初始化jenkins
4.1.# service jenkins start //启动jenkins服务
4.2.默认jenkins管理页面是ip:8080.
4.3.根据提示到指定目录 # vi initialAdminPassword.拿到一串密码
4.4.安装插件,选择推荐安装。
4.5.填写admin账号密码
jenkins到目前就算安装完成了。
1.新建项目
2.项目的配置
dotnet restore,publish中间遇到的几个坑
1.dotnet 找不到命令 dotnet command not found
解决办法:系统管理配置环境变量
# echo $PATH //查看系统的path变量
2.构建提示 bower command not found
# npm install bower -g //安装bower组件
pwd
ls
echo $PATH
whoami
which dotnet
dotnet --info
dotnet --version
echo '============================begin restore======================================='
dotnet restore
echo '============================cd web app======================================='
cd ./src/NetCoreWebApp
echo '============================begin build======================================='
#dotnet build -c:Release --no-incremental
rm -rf $WORKSPACE/jenkins_publish
mkdir $WORKSPACE/jenkins_publish
dotnet publish -r centos.7-x64 -c:Release -o $WORKSPACE/jenkins_publish
### 此处只是简单的测试jenkins构建。所以构建后的产物只是简单的发布到本地机器。仅做demo演示
echo '============================产物发布到服务器======================================='
rm -rf /salesystem/NetCoreWebApp
mkdir /salesystem/NetCoreWebApp
cp -r $WORKSPACE/jenkins_publish/* /salesystem/NetCoreWebApp/
成果
构建使用参数指定分支
完整的构建输出日志。构建脚本来自上面的shell
构建之后 copy到运行目录,run起来