官方参考:
官方语法参考:syntax/
脚本:
pipeline {
agent any
environment {
def ITEMNAME = "erp"
def DESTPATH = "/home/ops/testpipe"
def codePATH="/var/lib/jenkins/workspace/test_pipeline"
}
stages {
stage('代码拉取'){
steps {
echo "checkout from ${ITEMNAME}"
git url: ' git@gitlab.1***.cn:fangxin-tech/erp.git', branch: 'master'
}
}
stage('目录检查') {
steps {
echo "检查${DESTPATH}目录是否存在"
script{
def resultUpdateshell = sh script: 'ls ${DESTPATH}'
if (resultUpdateshell == 0) {
skip = '0'
return
}
}
}
}
stage('服务检查') {
steps {
echo "检查nginx进程是否存在"
script{
def resultUpdateshell = sh script: 'ps aux|grep nginx|grep -v grep'
if (resultUpdateshell == 0) {
skip = '0'
return
}
}
}
}
stage('supserver检查') {
steps {
echo "检查supserver是否存活"
script{
def resultUpdateshell = sh script: 'ps -ef |grep supervisor|grep -v grep'
if (resultUpdateshell == 0) {
skip = '0'
return
}
}
}
}
stage('发布确认') {
steps {
input "检查完成,是否发布?"
}
}
stage('代码推送') {
steps {
echo "code sync"
sh "cp ${codePATH}/* ${DESTPATH}/ -fr"
}
}
stage('gulp检查') {
steps {
echo "编译css和js文件"
script{
// def resultUpdateshell1 = sh script: 'cp -fr /home/ops/erp/node_modules ${DESTPATH}/'
// def resultUpdateshell2 = sh script: 'cp -fr /home/ops/erp/.env ${DESTPATH}/'
def resultUpdateshell3 = sh script: 'cd ${DESTPATH} && composer install'
def resultUpdateshell4 = sh script: 'cd ${DESTPATH} && /home/ops/testpipe/node_modules/.bin/gulp'
def resultUpdateshell5 = sh script: 'cd ${DESTPATH} && php artisan migrate'
def resultUpdateshell6 = sh script: 'cd ${DESTPATH} && php artisan queue:restart'
}
}
}
}
}
阅读(1035) | 评论(0) | 转发(0) |