gitlab 触发Jenkins简单示例

// Uses Declarative syntax to run commands inside a container.
pipeline {
    agent {
        label "test"
    }
    post {
      failure {
        updateGitlabCommitStatus name: 'Jenkins Pipeline', state: 'failed'
      }
      success {
        updateGitlabCommitStatus name: 'Jenkins Pipeline', state: 'success'
      }
    }
    options {
      gitLabConnection('scm-gitlab')
    }
    triggers {
        gitlab(
            triggerOnPush: false,
            triggerOnMergeRequest: true, triggerOpenMergeRequestOnPush: "never",
            triggerOnNoteRequest: true,
            noteRegex: "jenkins build",
            skipWorkInProgressMergeRequest: true,
            ciSkip: false,
            setBuildDescription: true,
            addNoteOnMergeRequest: true,
            addCiMessage: true,
            addVoteOnMergeRequest: true,
            acceptMergeRequestOnSuccess: false,
            branchFilterType: "NameBasedFilter",
            includeBranchesSpec: "master",
            excludeBranchesSpec: "",
            pendingBuildName: "Jenkins Pipeline",
            cancelPendingBuildsOnUpdate: false,
            // secretToken: "abcdefghijklmnopqrstuvwxyz0123456789ABCDEF")
        )
    }
    stages {
        stage('build') {
            steps {
                script {
                    echo "build"
                }
            }
        }
        stage('deploy') {
            steps {
                script {
                    echo "deploy"
                }
            }
        }
    }
}

  

posted @ 2022-08-18 15:23  JPinsz  阅读(119)  评论(0编辑  收藏  举报