I have [Copy Artifact](https://wiki.jenkins.io/display/JENKINS/Copy+Artifact+Plugin) Plugin installed & trying to build and deploy through jenkins pipeline with following Jenkinsfile

Parameter `DEPLOY_BUILD_NUMBER` default to current build number. I want to make it such a way pipeline should build and deploy if `DEPLOY_BUILD_NUMBER` is current build number OR just deploy whatever build number specified for `DEPLOY_BUILD_NUMBER`

```
pipeline {
    agent { label 'windows' }

    parameters {
        string(
            name: 'DEPLOY_BUILD_NUMBER',
            defaultValue: '${BUILD_NUMBER}',
            description: 'Fresh Build and Deploy OR Deploy Previous Build Number'
        )
    }

    stages {
        stage ('Build') {
            steps {
                echo "Building"
            }
            post {
                success {
                    archiveArtifacts artifacts: 'build.tar.gz', fingerprint: true
                }
            }
        }
        stage ('Deploy') {
            steps {
                echo "Deploying...."
                script {
                    step ([$class: 'CopyArtifact',
                    projectName: '${JOB_NAME}',
                    filter: "*.tar.gz"]);
                }
            }
        }
    }
    post {
        always {
            cleanWs()
        }
    }
}

```

When I run this pipeline I get following error 

```
java.lang.UnsupportedOperationException: no known implementation of interface jenkins.tasks.SimpleBuildStep is named CopyArtifact

```

Also tried 

```
stage ('Deploy') {
        steps {
            echo "Deploying...."
            copyArtifacts filter: '*.tar.gz', fingerprintArtifacts: true, projectName: '${JOB_NAME}'
        }
    }

```

which failed with following error 

```
java.lang.NoSuchMethodError: No such DSL method 'copyArtifacts' found among steps

```

and 

```
stage ('Deploy') {
    steps {
        echo "Deploying...."
        script {
                copyArtifacts filter: '*.tar.gz', fingerprintArtifacts: true, projectName: '${JOB_NAME}'
            }
    }
}

```

which gave me 

```
java.lang.NoSuchMethodError: No such DSL method 'copyArtifacts' found among steps

```

What is the correct syntax for copyArtifacts ? what I am missing here ?