#!groovy

// Load shared pipeline library
@Library('velox') _

properties([
    // Only keep Jenkins builds around for 14 days
    buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '14', numToKeepStr: '')),
    parameters([
        string(name: 'APIM_MANAGEMENT', defaultValue: '', description: 'The V5 API Management Server with the default test data'),
        string(name: 'APIM_USERNAME', defaultValue: '', description: 'Username to login to api manager'),
        string(name: 'APIM_PASSWORD', defaultValue: '7iron-hide', description: 'Password to login to api manager'),
        choice(
            name: 'npm_config_registry',
            description: 'NPM registry to install dependencies from. CI (default), or release-staging.',
            choices: [
                'http://apic-ci-npm.hursley.ibm.com:4873/', // ci registry
                'http://apim-ci1.rtp.raleigh.ibm.com:8080/', // staging registry
            ],
        ),
    ]),
])

// abort build if these parameters aren't given
assert params.APIM_MANAGEMENT
assert params.APIM_USERNAME

veloxPipeline { p ->
    
    env.CAPTURING_LOGGER = 'true'
		
    stage('node 14') {
        p.useNode('14')
        sh '''
            git clean -fxd
            npm install --prefer-offline
            npm test
            npm run server-test
        '''
    }

}
