Script jenkin

 String[] excludes = [

    ".idea",

    ".vscode",

".git",

".env"

]


def document_root = "/var/www/v4-api.hidemium.com"

def document_dashboard = "/var/www/v4-dashboard.hidemium.com"

def exclude_file = "/tmp/ssh-webhook.txt"

def git_url = "http://git.minhhoangjsc.com:8080/web-projects/multiple_browsers"

def git_branch = "V4"

def git_creds = "aa0c901d-965f-4edc-a3dd-d5f391f66247"


def loop_of_sh(list,tmp) {

    list.each { item ->

        sh "echo ${item} > $tmp"

    }

}


def ex(param){

    currentBuild.result = "ABORTED"

    error("Error: " + param)

}


pipeline {

    agent none

    stages {

        stage("Deploy V4-API") {

parallel {

stage('v4-webservices') {

agent { label 'v4-webservices'}

steps {

echo "Pulling code"

git branch: "$git_branch",

credentialsId: "$git_creds",

url: "$git_url"



sh """

bash -c "composer install --optimize-autoloader --no-dev"

"""

sh "rm -rf ${exclude_file}"

script {

loop_of_sh(excludes,exclude_file)

}


dir("$document_root"){

sh """

rsync -avz --exclude-from ${exclude_file} $env.WORKSPACE/ $document_root &&

php artisan config:clear &&

php artisan cache:clear &&

php artisan migrate --force &&

php artisan view:clear &&

php artisan queue:restart

"""

}

}

}

stage('v4-api-us') {

agent { label 'v4-api-us'}

steps {

echo "Pulling code"

git branch: "$git_branch",

credentialsId: "$git_creds",

url: "$git_url"



sh """

bash -c "composer install --optimize-autoloader --no-dev"

"""

sh "rm -rf ${exclude_file}"

script {

loop_of_sh(excludes,exclude_file)

}


dir("$document_root"){

sh """

rsync -avz --exclude-from ${exclude_file} $env.WORKSPACE/ $document_root &&

php artisan config:clear &&

php artisan cache:clear &&

php artisan migrate --force &&

php artisan view:clear &&

php artisan queue:restart

"""

}

}

}

stage('v4-storage') {

agent { label 'v4-storage'}

steps {

echo "Pulling code"

git branch: "$git_branch",

credentialsId: "$git_creds",

url: "$git_url"



sh """

bash -c "composer install --optimize-autoloader --no-dev"

"""

sh "rm -rf ${exclude_file}"

script {

loop_of_sh(excludes,exclude_file)

}


dir("$document_root"){

sh """

rsync -avz --exclude-from ${exclude_file} $env.WORKSPACE/ $document_root &&

php artisan config:clear &&

php artisan cache:clear &&

php artisan migrate --force &&

php artisan view:clear &&

php artisan queue:restart

"""

}

}

}

}

        }

    }

    post {

        always {

            echo "Post Script"

        }

    }

}


Nhận xét

Bài đăng phổ biến từ blog này

Đoạn js thêm code vào màn hình khi chạy auto

Các cách fix mongodb khi bị lỗi

Gỡ mysql và cài lại