Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/ab-connector / Jenkinsfile
Size: Mime:
def GITHUB_REPO = "https://github.com/DoodleScheduling/ab-connector.git"
def STATUS_CONTEXT = "ci/jenkins"

// void setBuildStatus(String url, String context, String message, String state) {
//     step([
//         $class: "GitHubCommitStatusSetter",
//         reposSource: [$class: "ManuallyEnteredRepositorySource", url: url.replaceFirst(/\.git$/, "")],
//         contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
//         errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
//         statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
//     ])
// }

node('jenkins') {
    stage('setup') {
        checkout scm

        script {
            PACKAGE = readJSON file: 'package.json'
            VERSION = "${PACKAGE.version}"
            TAG = 'latest'
            if (env.BRANCH_NAME != 'master') {
                VERSION = "${VERSION}-dev.${env.BUILD_NUMBER}"
            }
        }
    }

    stage('install') {
        // setBuildStatus ("${GITHUB_REPO}", "${STATUS_CONTEXT}", 'Installing dependencies', 'PENDING')
        try {
            sh "yarn install"
        } catch(error) {
            // setBuildStatus ("${GITHUB_REPO}", "${STATUS_CONTEXT}", 'Could not install dependencies', 'FAILURE')
            error('install failed')
        }
    }

    stage('lint') {
        // setBuildStatus ("${GITHUB_REPO}", "${STATUS_CONTEXT}", 'Linting source code', 'PENDING')
        try {
            sh "yarn lint"
        } catch(error) {
            // setBuildStatus ("${GITHUB_REPO}", "${STATUS_CONTEXT}", 'Found problems in source code', 'FAILURE')
            error('lint failed')
        }
    }

    stage('test') {
        try {
            sh "yarn test"
        } catch(error) {
            error('tests failed')
        }
    }

//    if (env.BRANCH_NAME == 'master')
//    stage('publish') {
//        setBuildStatus ("${GITHUB_REPO}", "${STATUS_CONTEXT}", 'Deploying', 'PENDING')
//
//        withCredentials([string(credentialsId: 'ONESKY_SECRET_KEY', variable: 'ONESKY_SECRET_KEY')]) {
//            sh """
//            echo "publishing version ${VERSION} to registry..."
//            echo "//npm-proxy.fury.io/mfsTqYdDz3bsKFQJuMAR/tmf/:_authToken=gzE3v6EJzrJ4ptsqoadm" > ~/.npmrc
//            echo "ONESKY_PUBLIC_KEY=a1wBmLzC1dlH3dpG8i72a0grw8rTN8PN" >> .env
//            echo "ONESKY_SECRET_KEY=$ONESKY_SECRET_KEY" >> .env
//            yarn gulp publish && \
//            echo "🚀"
//            """
//        }
//
//        setBuildStatus ("${GITHUB_REPO}", "${STATUS_CONTEXT}", 'Deployed', 'SUCCESS')
//    }

}