Using Artifactory plugin in Jenkins declarative pipeline
You can have conditionals in your declarative pipeline by using the when-block inside a stage. There is a plugin called "environment injector" which lets you set variables outside of the pipeline-script which is nice. Also if you put the step below the other steps, it won't execute if they fail.

 when {
    environment name: 'pushArtifact', value: 'true'
  }
  steps{
     //push artifact  
  }