使用jenkins部署项目
IP | 安装环境 | 系统 |
---|---|---|
192.168.201.147 | tomcat+jenkins | centos8/redhat8 |
192.168.201.149 | tomcat | centos8/redhat8 |
需求:通过192.168.201.147主机 部署jenkins 将项目打包传输的192.168.201.149主机 并可以通过浏览器访问到项目网页
创建项目
编写流水线脚本
pipeline {
agent any
stages {
stage("pull code"){
steps {
git 'https://github.com/chendao2015/tomcat-java-demo.git'
}
}
}
}
命令行查看项目保存的路径
[root@localhost ~]# cd .jenkins/workspace/test
[root@localhost test]# ls
db Dockerfile LICENSE pom.xml README.md src
打包并传输项目
[root@localhost ~]# yum -y install maven
编写脚本
pipeline {
agent any
stages {
stage("pull code"){
steps {
git 'https://github.com/chendao2015/tomcat-java-demo.git'
}
}
stage("make pkg"){
steps {
sh """
mvn clean package -Dmaven.test.skip=true
"""
}
}
}
}
查看项目中test文件