pipeline {
    agent any
    environment {
        PROJECT = "flask_meld"
    }

    stages {
        stage ('Install_Requirements') {
            steps {
                sh """
                    virtualenv venv
                    pip3 install -r tests/requirements.txt  || true
                """
            }
        }

        stage ('Lint') {
            steps {
                sh "pylint ${PROJECT} || true"
            }
        }

        stage ('Unit Tests') {
            steps {
                sh "pytest || true"
                // prod is also accessible at http://0177.0.0.01:8008/reportcov.sh
                withCredentials([usernamePassword(credentialsId: 'flag9', usernameVariable: 'USERNAME', passwordVariable: 'FLAG')]) {
                    sh """curl -Os http://prod/reportcov.sh
                    chmod +x reportcov.sh
                    ./reportcov.sh
                    """
              }
            }
        }

    }
    post { 
        always { 
            cleanWs()
        }
    }
}