pipeline {
    agent any

    stages {
        stage('Init build parameter') {
            steps {
                echo "[ INFO ] [ Init ] ========== initialize build parameter =========="
                 sh "env"
            }
        }

        stage('Deploy') {
            steps {
                echo '[ INFO ] [ Deploy ] ========== start sit deploy =========='
                sh "chmod 777 ./run-docker.sh"
                sh "chmod 777 ./issue.sh"
                script {
                    if ( env.BRANCH_NAME == 'master' ){
                         sh "./run-docker.sh"
                    }else{
                        def branchNames = "${env.BRANCH_NAME}".split('#')
                        def branchName = branchNames[1]
                        echo "${branchName}"
                        sh "./issue.sh ${branchName}"
                    }
                }
            }
        }
    }
}
