Commit 7c5b18a2 authored by carignani's avatar carignani
Browse files

add oas validation and email notification

parent 1650fa92
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ pipeline {
    options {
        disableConcurrentBuilds()
        gitLabConnection('Gitlab for 3GPP')
        gitlabBuilds(builds: ["Resolve", "Validate"])
        gitlabBuilds(builds: ["Resolve", "Validate YANG", "Lint YANG", "Validate OpenAPI"])
    }
     
	agent any
@@ -19,7 +19,7 @@ pipeline {
                updateGitlabCommitStatus name: 'Resolve', state: 'pending'
                dir('data-models') {
                    checkout changelog: true, poll: false, scm: [
                        $class: 'GitSCM', branches: [[name: "origin/${env.gitlabSourceBranch}"]],
                        $class: 'GitSCM', branches: [[name: "${env.gitlabAfter}"]],
                        doGenerateSubmoduleConfigurations: false,
                        extensions: [[$class: 'PreBuildMerge', options: [
                        fastForwardMode: 'FF', mergeRemote: 'origin', mergeStrategy: 'DEFAULT', 
@@ -46,7 +46,7 @@ pipeline {
				}
            }
		}
		stage('Validate') {
		stage('Validate YANG') {
    		steps{
    		    updateGitlabCommitStatus name: 'Validate', state: 'pending'
    			sh 'echo Validate stage'
@@ -54,7 +54,7 @@ pipeline {
    			updateGitlabCommitStatus name: 'Validate', state: 'success'
			}
		}
		stage('Lint') {
		stage('Lint YANG') {
    		steps{
    		    updateGitlabCommitStatus name: 'Lint', state: 'pending'
    			sh 'echo Lint stage'
@@ -62,6 +62,14 @@ pipeline {
    			updateGitlabCommitStatus name: 'Lint', state: 'success'
			}
		}
        stage('Validate OpenAPI') {
            steps{
                updateGitlabCommitStatus name: 'Validate', state: 'pending'
                sh 'echo Validate stage'
                sh 'bash ./scripts/validate-all.sh ./data-models/OpenAPI'
                updateGitlabCommitStatus name: 'Validate', state: 'success'
            }
        }
		stage('Deploy to FTP') {
    		steps{
    			sh 'echo DEPLOY stage'
@@ -75,12 +83,24 @@ pipeline {
				if (env.resolveSucceded == "false") {
					updateGitlabCommitStatus name: 'Resolve', state: 'failed'
				}
                RECIPIENT = """${sh(
                    returnStdout: true,
                    script: "cd apis && git log --format='%ae' HEAD^!"
                )}"""
			}

			updateGitlabCommitStatus name: 'Validate', state: 'failed'
			updateGitlabCommitStatus name: 'Validate OpenAPI', state: 'failed'

			mail to: 'cti_support@etsi.org',
				subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
				body: "Something is wrong with ${env.BUILD_URL}"
            echo "Sending email to: ${RECIPIENT}"
            mail to: "${RECIPIENT}",
                subject: "[3GPP Forge] Validation failed: ${currentBuild.fullDisplayName}",
                body: "Your contribution to 3GPP Forge was applied successfully; however, " +
                    "after running the validation process for all the files in the repository, " +
                    "some errors were detected (they may, or may not be related to your own " +
                    "contribution). Please check the 'Console output' at ${env.BUILD_URL}" 
		}
	}
}