Chinaunix首页 | 论坛 | 博客

OPS

  • 博客访问: 488608
  • 博文数量: 117
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1210
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 14:50
个人简介

hellow 运维

文章分类

全部博文(117)

文章存档

2019年(1)

2018年(1)

2017年(45)

2016年(38)

2015年(32)

我的朋友

分类: 系统运维

2017-10-12 15:01:13

官方参考:
官方语法参考: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'

}
}
}
}

阅读(974) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~