# Language setting http://docs.shippable.com/ci/languages/node/ language: node_js # Integrations are used to connect external resources to CI # http://docs.shippable.com/integrations/overview/ integrations: # adding docker hub integration so that credentials are available to CI Job # http://docs.shippable.com/platform/integration/dockerRegistryLogin/ hub: - integrationName: dr_dh type: dockerRegistryLogin # use this to control what branches get built. # http://docs.shippable.com/ci/advancedOptions/branches/ branches: only: - master # using pre-defined build variables # full list http://docs.shippable.com/ci/advancedOptions/environmentVariables/ env: global: - TEST_RESULTS_DIR=$SHIPPABLE_REPO_DIR/shippable/testresults - CODE_COVERAGE_DIR=$SHIPPABLE_REPO_DIR/shippable/codecoverage - TESTS_LOC_DIR=$SHIPPABLE_REPO_DIR/tests - MOD_LOC=$SHIPPABLE_REPO_DIR/node_modules/.bin/ - DOCKER_REPO="node_app" - DOCKER_ACC=devopsrecipes # {account name} - SHIP_IMG_RES=$DOCKER_REPO"_img_dh" build: # http://docs.shippable.com/ci/shippableyml/#ci ci: # npm mirrors can sometimes be flacky, better to use shippable_retry # http://docs.shippable.com/ci/advancedOptions/retry/ - node -v - npm install - mkdir -p $TEST_RESULTS_DIR && mkdir -p $CODE_COVERAGE_DIR - pushd $TESTS_LOC_DIR - $MOD_LOC/mocha --recursive "$TESTS_LOC_DIR/**/*.spec.js" -R mocha-junit-reporter --reporter-options mochaFile=$TEST_RESULTS_DIR/testresults.xml - $MOD_LOC/istanbul --include-all-sources cover -root "$SHIPPABLE_REPO_DIR/routes" $SHIPPABLE_REPO_DIR/node_modules/mocha/bin/_mocha -- -R spec-xunit-file --recursive "$TESTS_LOC_DIR/**/*.spec.js" - $MOD_LOC/istanbul report cobertura --dir $CODE_COVERAGE_DIR - popd # http://docs.shippable.com/ci/shippableyml/#post_ci post_ci: - docker build -t $DOCKER_ACC/$DOCKER_REPO:$BRANCH.$BUILD_NUMBER . - if [ "$IS_PULL_REQUEST" != true ]; then docker push $DOCKER_ACC/$DOCKER_REPO:$BRANCH.$BUILD_NUMBER; fi #this will be ignored if you are not using Assembly Lines to trigger another job after ci on_success: - shipctl put_resource_state $SHIP_IMG_RES versionName $BRANCH.$BUILD_NUMBER ## OPTIONAL : In case you want to use this image in CD Assembly Lines resources: - name: node_app_img_dh type: image integration: dr_dh # replace with your integration name versionTemplate: sourceName: "devopsrecipes/node_app" # replace with your Hub URL isPull: false versionName: latest jobs: - name: node_app_runCI type: runCI dependencyMode: strict triggerMode: parallel steps: - OUT: node_app_img_dh flags: - node_app