Using Jenkins File Operations Plugin for File Management in Pipelines
This article introduces the Jenkins File Operations plugin, explains how to install it, generate the required DSL, and run a pipeline that creates, lists, and cleans up files, providing a complete code example and build log screenshots for reference.
The Jenkins File Operations plugin enables convenient file handling—upload, download, move, rename, and delete—directly within Jenkins pipelines. After installing the plugin from the official Jenkins site, you can generate the DSL needed to configure file operations.
To run a pipeline using the plugin, define a Jenkinsfile that includes an agent any and a stage where a script block calls fileOperations([fileCreateOperation(fileContent: 'devops', fileName: 'test.json')]) , followed by a shell command sh " ls -l " and a sleep 20 to observe the results.
Example pipeline code:
pipeline {
agent any
stages {
stage('Hello') {
steps {
script {
fileOperations([fileCreateOperation(fileContent: 'devops', fileName: 'test.json')])
sh " ls -l "
sleep 20
}
}
}
}
}The build log shows the created file and the output of the ls -l command, confirming that the plugin works as expected. Additional screenshots illustrate the installation process, DSL generation, pipeline execution, and build log details.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.