Jenkinsfile 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#!/usr/bin/groovy

@Library('gcloud-pipeline-library') _

pipeline {
    agent {
        label 'base7'
    }

    options {
        buildDiscarder(logRotator(numToKeepStr: '10'))
        timeout(time: 1, unit: 'HOURS')
        timestamps()
        gitLabConnection('IFNE gitlab')
    }

    triggers {
        gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All')
    }

    stages {
        stage('Setup') {
            steps {
                devBuildPrepare()
            }
        }

        stage('Quality gate') {
            when {
                expression {
                    env.BRANCH_NAME == 'master'
                }
            }
            steps {
                withSonarQubeEnv('IFNE Sonar') {
                    sonarRunScanner()
                }
                timeout(time: 1, unit: 'HOURS') {
                    waitForQualityGate abortPipeline: true
                }
            }
        }

    }

    post {
        always {
            deleteDir()
        }

        success {
            updateGitlabCommitStatus(name: 'jenkins', state: 'success')
        }
        failure {
            updateGitlabCommitStatus(name: 'jenkins', state: 'failed')
        }
    }
}