'How to use artifactResolver in Jenkinsfile pipeline steps?

I am trying to use artifactResolver in a Jenkins pipeline step. However, it is failing.

Trying the following config:

pipeline {
    agent any

    stages {
        stage('Download artifact') {
            steps {
                artifactResolver {
                  artifacts {
                    artifact {
                        groupId('ch.qos.logback')
                        artifactId('logback-classic')
                        version('1.1.1')
                        classifier('sources')
                    }
                  }
                }
            }
        }
    }
}

However, I get the following error when I build on Jeninks:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 7: Missing required parameter: "artifacts" @ line 7, column 17.
                   artifactResolver {
                   ^


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source