0

Is there any way to compare two files in jenkins scripted pipeline and mail the difference? We can write a batch script and call it in jenkins but want to understand if there is any way to do it in jenkins pipeline.

Any suggestions on this is highly appreciated.

  • What kind of a file is it? If it is a text file, you can use the readFile method within the Jenkinsfile to read it and check the size. Otherwise, it might make more sense to do this through a shell script, as Jenkins might not allow you to create an instance of the File class due to security reasons - see https://stackoverflow.com/questions/30608444/in-jenkins-job-create-file-using-system-groovy-in-current-workspace/32514581#32514581 – Sharp May 28 '22 at 18:40
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community May 29 '22 at 21:37

1 Answers1

0

If you only want to compare size, the option suggested by Sharp would be a solution. Apart from that, if you want to get a diff, there aren't a lot of built in tools within Jenkins that can help you. You could try the Artifact Diff plugin, but it hasn't been updated in years and may not have the necessary capabilities you are looking for. Using external diff tools you can call would be the best way to go here. As you mentioned, you would have to write a batch script that performs the diff and writes it into a patch file. You could then use Jenkins to email the patch files if they exist.

M B
  • 2,700
  • 2
  • 15
  • 20