美文网首页
DevOps之jenkinsfile示例

DevOps之jenkinsfile示例

作者: OrangeLoveMilan | 来源:发表于2020-05-25 10:23 被阅读0次

    贴出一个nodejs项目的jenkinsfile,与dockerfile结合,实现持续发布的功能

    #!groovy
    pipeline {
       agent any
       stages{
               stage('Build') {
                parallel {
                    stage('Lint') {
                        steps {
                          
                                sh "npm run tslint"
                            
                        }
                    }
                    stage('Compile') {
                        steps {
                            
                                sh "npm run build"
                            }             
                     }
                    
                    }               
                }
                stage('zip'){
                            steps{
                               sh """
                                  rm -rf *.zip
                                  zip -r -q demo.zip *
                                  """
           
           }
       }
         
                stage('docker build'){
                            steps{
                                sh """
                                    docker build -f ./Dockerfile . -t node-test:v$BUILD_NUMBER
                                    docker login reg.qiniu.com -u lugo@test.com -p test33
                                    docker tag node-test:v$BUILD_NUMBER  reg.qiniu.com/lugo/node-test:v$BUILD_NUMBER
                                    docker push reg.qiniu.com/lugo/node-test:v$BUILD_NUMBER          
                                    """
           }
       }
                stage('ansible deploy'){
                            steps{
                                sh """
                                    ansible-playbook /etc/ansible/playbook/node_test.yml  -e image_name=reg.qiniu.com/lugo/node-test:v$BUILD_NUMBER
                                    """ 
            }
        }
               }
       }
    

    相关文章

      网友评论

          本文标题:DevOps之jenkinsfile示例

          本文链接:https://www.haomeiwen.com/subject/omweahtx.html