Skip to content
Snippets Groups Projects
  • ViaFerrata's avatar
    e7ca90a0
    - Change folder structure for continuous integration and to better suit... · e7ca90a0
    ViaFerrata authored
    - Change folder structure for continuous integration and to better suit standard python package structures
    - add Dockerfile, Jenkinsfile, requirements for CI
    - add License, Changelog
    - remove globals file, not necessary anymore
    - simplify geo binning, change geo_fix parameter to det_geo parameter
    - better readout of run_id variable
    e7ca90a0
    History
    - Change folder structure for continuous integration and to better suit...
    ViaFerrata authored
    - Change folder structure for continuous integration and to better suit standard python package structures
    - add Dockerfile, Jenkinsfile, requirements for CI
    - add License, Changelog
    - remove globals file, not necessary anymore
    - simplify geo binning, change geo_fix parameter to det_geo parameter
    - better readout of run_id variable
Jenkinsfile 2.22 KiB
#!groovy
CHAT_CHANNEL = '#deep_learning'
DEVELOPERS = ['mmoser@km3net.de, michael.m.moser@fau.de']

def projectProperties = [
        disableConcurrentBuilds(),
        gitLabConnection('KM3NeT GitLab')
]
properties(projectProperties)

node('master') {

    // Start with a clean workspace
    // cleanWs()
    checkout scm

    def docker_image = docker.build("orcasong-container:${env.BUILD_ID}")

    docker_image.inside("-u root:root") {
        gitlabBuilds(builds: ["install", "test"]) {
            updateGitlabCommitStatus name: 'install', state: 'pending'
            stage('build') {
                try {
                    sh """
                        pip install .
                    """
                    updateGitlabCommitStatus name: 'install', state: 'success'
                } catch (e) {
                    // sendChatMessage("Build Failed")
                    sendMail("Build Failed")
                    updateGitlabCommitStatus name: 'install', state: 'failed'
                    throw e
                }
            }
            updateGitlabCommitStatus name: 'test', state: 'pending'
            stage('test') {
                try {
                    sh """
                        python -c "import orcasong"
                    """
                    updateGitlabCommitStatus name: 'test', state: 'success'
                } catch (e) {
                    // sendChatMessage("Build Failed")
                    sendMail("Build Failed")
                    updateGitlabCommitStatus name: 'test', state: 'failed'
                    throw e
                }
            }
        }
    }
}


def sendChatMessage(message, channel=CHAT_CHANNEL) {
    rocketSend channel: channel, message: "${message} - [Build ${env.BUILD_NUMBER} ](${env.BUILD_URL})"
}


def sendMail(subject, message='', developers=DEVELOPERS) {
    for (int i = 0; i < developers.size(); i++) {
        def developer = DEVELOPERS[i]
        emailext (
            subject: "$subject - Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
            body: """
                <p>$message</p>
                <p>Check console output at <a href ='${env.BUILD_URL}'>${env.BUILD_URL}</a> to view the results.</p>
            """,
            to: developer
        )
    }
}