Newer
Older
DummyJnkPL / Jenkinsfile
@Benoit Donneaux Benoit Donneaux on 8 Dec 2017 1 KB Fail properly if no config
#!/usr/bin/env groovy

def libInit =[
	remote: 'https://code.digital-me.nl/git/DEVops/DummyJnkLibInit.git',
	branch: 'master',
	credentialsId: null,
]

try {
	echo 'Trying to load shared libraries...' 
	library identifier: "libInit@${libInit.branch}", retriever: modernSCM(
		[$class: 'GitSCMSource',
			remote: libInit.remote,
			credentialsId: libInit.credentialsId]
	)
	echo 'Shared library loaded'
} catch (error) {
	echo "Could not load shared libraries: ${error.message}"
	exit(1)
}

// Configuration
def config = initPipeline()
if (config == null) {
    currentBuild.result = 'FAILURE'
    return
}
 
// PIPELINE

try {
    stage('Static code validation') {
        if (config.compile) {
            label('docker') {
                echo 'Validation goes here'
            }
        } else {
           	echo 'Not validating'
        }
    }
    stage('Test') {
        if (config.test) {
        	label('docker') {
            	echo 'Testing goes here...'
            }
        } else {
           	echo 'Not testing'
        }
    }
    currentBuild.result = 'SUCCESS'
} catch (Exception error) {
    currentBuild.result = 'FAILURE'
} finally {
    stage('Build result notification') {
        if (config.notify) {
        	echo 'Notification goes here'
        }
    }
}