Upload a CSV files in Jenkins pipeline Job
Most of Jenkins build’s doesn’t require to upload a CSV file, but some of the builds required approvals for one stage to another stage. Some of the jobs are parameterized builds with some manual interaction to trigger those build’s.
For Example,
I have three dependent applications. I want to execute the one by one based on dynamic input of 1st application. Instead of creating new applications, we can configure that application execution processes with latest code changes with help of Jenkins parameterized job. Here stage 1 required either CSV file, string, integer type to process the build.Based on Jenkins parameterized to build we can load the stage one input type.
pipeline {
agent any
stages {
stage('EnterUserInput') {
steps {
script {
def userInputTxt = input(
id: 'inputTextbox', message: 'Please enter JOB Description', parameters: [
[$class: 'TextParameterDefinition', description: 'String or Integer etc..',name: 'input']
])
echo ("JOB Description is: ${userInputTxt}")
}}
}
stage('Upload a CSV') {
steps {
script {
def inputCSVPath = input message: 'Upload file', parameters: [file(name: 'Test.csv', description: 'Upload only CSV file')]
def csvContent = readFile "${inputCSVPath}"
echo ("CSV FILE PATH IS : ${inputCSVPath}")
echo("CSV CONTENT IS: ${csvContent}")
}
echo env.STAGE_NAME
echo '=========== Upload a CSV =============='
}
}
}
}
Note: We can customize the above script in smart way according to our requirement. It’s only practice(i.e. Test) script.
For more detailed way, please visit below link:
== If you find any thing wrong please let me know i will update my self ==