1

I'm trying to implement a pipeline in which, depending on the choice of parameter, the user sees either text input or file input. I use Active Choices Parameter: First: First Parameter Second: First Parameter then i need to get this values in pipeline code for example:

pipeline {
  agent any

  stages {
    stage('Demo Active Choices Parameter') {
      steps {
        echo "${services}"
      }
    }
  }
}

with text input - it works how can i get the file in pipeline? thank you and sorry for english.

1 Answers1

0

It can be solved with use this html input:

<input name='file' type='file' jsonaware='true'>

And in pipeline i use this library for jenkins: https://github.com/janvrany/jenkinsci-unstashParam-library

@Library("jenkinsci-unstashParam-library") _
pipeline {
    agent any
    stages {
        stage('Stage') {
            steps {
                script {
                    if (object == 'variable') {
                        sh "echo ${input}"
                        //SOMETHING ELSE
                    }
                    else if (object == 'file') {
                        def input_file = unstashParam "input"
                        sh "cat ${input_file}"
                        //SOMETHING ELSE
                    }
                }
            }
        }
    }
}