def call(body) {
  def config = [:]
  body.resolveStrategy = Closure.DELEGATE_FIRST
  body.delegate = config
  body()
  node(config.node_label) {
    // Wipe the workspace so we are building completely clean
    deleteDir()
    checkout scm
    stage('Style checks') {
      withEnv(['PATH+=/opt/chef/embedded/bin/']) {
        sh(
          script: '''
          # Checking json syntax
          for file in $(find . -type f -name "*.json");do
            jq empty ${file};
          done
          # Checking ruby syntax and styles
          cookstyle .
          '''
        )
      }
    }
    // Skipping integration tests, if configured
    if (config.int_tests) {
      stage('Integration tests') {
        withEnv(['PATH+=/opt/chef/embedded/bin/']) {
          ansiColor('xterm') {
            sh(
              script: '''
              /var/lib/jenkins/irrigate-chef-ci/scripts/ci.sh
              '''
            )
          }
        }
      }
    }
  }
}
