Download File from user

Jenkins setup:

HI I need use user file from my pipeline. I wanted that user can choise file as parametr.

pipeline {
    agent any
    parameters {
        file(name: 'UPLOAD_FILE', description: 'Select a file to upload')
    }
    stages {
        stage('Copy File') {
            steps {
                
                script {
                    def uploadedFile = params.UPLOAD_FILE     
                    def destinationDir = "${env.WORKSPACE}"
                    
                    // Копируем файл в рабочую директорию
                    sh "cp  ${uploadedFile} ${destinationDir}"
                    echo "File copied to workspace."
                }
            }
        }
    }
}

From this, the user can select a file as an option, but it seems Jenkins is not loading it into the workspace. I have an error that value of uploadedFile is null

The regular file parameter doesn’t work in pipeline scripts afaik.
You should use the File Parameter plugin for this

1 Like

Thank you very much.