【Jenkins】Jenkinsfile
Using a Jenkinsfile
pipeline {
agent any
stages{
stage('Init'){
steps {
echo "Testing......"
}
}
stage('Build'){
steps {
echo "Building......"
}
}
stage('Deploy'){
steps {
echo "Code Deployed."
}
}
}
}
pipeline {
agent any
tools{
maven 'local maven'
}
parameters{
string(name: 'tomcat_dev', defaultValue: '1.1.1.1', description: 'Staging Server')
string(name: 'tomcat_prod', defaultValue: '2.2.2.2', description: 'Production Server')
}
triggers {
pollSCM('* * * * *')
}
stages{
stage (stage('build'Build'){
steps{steps {
sh 'mvn clean package'
}
post {
success {
echo '开始存档...'
archiveArtifacts artifacts: '**/target/*.war'
}
}
}
stage ('Deployments'){
parallel{
stage ('Deploy to Staging'){
steps {
sh "scp -i /Users/gaoyan/Documents/SunnyDemo/dev/tomcat-demo.pem.txt **/target/*.war ec2-user@${params.tomcat_dev}:/var/lib/tomcat8/webapps"
}
}
stage ("Deploy to Production"){
steps {
sh "scp -i /Users/gaoyan/Documents/SunnyDemo/dev/tomcat-demo.pem.txt **/target/*.war ec2-user@${params.tomcat_prod}:/var/lib/tomcat8/webapps"
}
}
}
}
}
}