【系统部署知识汇总】第18章——pipeline示例 + maven安装
程序员文章站
2022-06-03 22:54:04
...
pipeline
示例1
pipeline{
agent any
stages{
stage("get code"){
steps{
echo "get code from scm"
}
}
stage("package"){
steps{
echo "packge code"
}
}
stage("deploy"){
steps{
echo "deploy packge to node1"
}
}
}
}
示例2
pipeline{
agent any
stages{
stage("get code"){
steps{
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '06ac7536-b4d0-400f-ae10-fb71cdb266dc', url: '[email protected]:oldboy/monitor.git']]])
}
}
stage("package"){
steps{
sh 'cd /var/lib/jenkins/workspace/pipeline-job && tar czf /opt/web-$(date +%F).tar.gz .'
}
}
stage("deploy"){
steps{
sh 'scp /opt/web-$(date +%F).tar.gz 192.168.56.11:/var/www/html'
sh 'ssh 192.168.56.11 "cd /var/www/html/&&tar xf web-$(date +%F).tar.gz"'
}
}
}
}
maven安装
1、下载Maven 3安装包
官网:http://maven.apache.org/download.cgi
清华镜像:https://mirrors.tuna.tsinghua.edu.cn/apache/maven/
2、安装Maven
tar xf apache-maven-3.3.9-bin.tar.gz
mv apache-maven-3.3.9 /usr/local/
ln -s /usr/local/apache-maven-3.3.9/ /usr/local/maven
/usr/local/maven/bin/mvn -v
3、编辑/etc/profile文件,在末尾添加
export PATH=/usr/local/apache-maven-3.3.9/bin/:$PATH
下一篇: 二、platform设备驱动实验