How to mark a step as failed or unstable on timeout, instead of aborting build?
I've done something similar to this in the past:

stage('Step Tests') {
  steps {
    dir('test') {
      script {
        try {
          timeout(time: 5, unit: 'MINUTES', activity: true) {
            sh "yarn step-tests"
          }
        } catch (Exception e) {
          currentBuild.result = 'FAILURE'
        }
      }
    }
  }
}


I haven't tested this code exactly as I wrote it here, so think of this more as a kind of rough sketch rather than polished final product.