The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

File Parameter Plugin

withFileParameter: Bind file parameter

Binds an (alternative) file parameter to a local file near the workspace for convenience. Parameters can be retrieved in other ways, depending on the specific parameter type.

How to use it in a declarative pipeline:

pipeline {
  agent any
  parameters {
    base64File 'THEFILE'
  }
  stages {
    stage('Example') {
      steps {
        withFileParameter('THEFILE') {
          sh 'cat $THEFILE'
        }
      }
    }
  }
}
  
By default, there will be an error if there is no parameter for the build but you can ignore this error using the parameter attribute allowNoFile. In this case your Pipeline must take into account the possibility that the file does not exist:
pipeline {
  agent any
  parameters {
    base64File 'THEFILE'
  }
  stages {
    stage('Example') {
      steps {
        withFileParameter(name:'THEFILE', allowNoFile: true) {
          sh 'if [ -f "$THEFILE" ]; then cat $THEFILE; fi'
        }
      }
    }
  }
}
  
  • name : String
    Name of the parameter. Within the wrapper, this environment variable will be bound to the path of a temporary file.
  • allowNoFile : boolean (optional)
    By default, an error will be thrown if there is no file uploaded to the build. With this option, the build will proceed, and the environment variable will simply not be defined.

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.