Write a batch script to edit text in a .cs file
I wonder if anyone knows how to write a batch script to edit some text in a .cs file.
What I want to do is change “AssemblyVersion(“22.214.171.124″)” “AssemblyVersion(“1.0.0.x”)” where x++ for every time the job in jenkins is being built.
Best Regards Jan
- jenkins not able to connect to a repository
- github api to compare commits, response status is diverged
- maven deploy to tomcat cluster (multiple) in one line
- how to build eclipse rcp application from .product with ant on jenkins
- Jenkins git location
- how to configure Gerrit trigger to trigger only when master or branches changes excluding (refs/for/*)?
2 Solutions collect form web for “Write a batch script to edit text in a .cs file”
Do you want to use only a batch script for this? You could also use Execute Groovy Script option and write some simple groovy script to achieve this
file = new File("folder/path/myfile.cs") fileText = file.text; fileText = fileText.replaceAll(srcExp, replaceText); file.write(fileText);
You can also use the availabe environment variables from your jenkins job to construct your replace text. These variables will be present at /env-vars.html
Stay away from “batch-file automation” – will only cause you grief.
(for a starter, different versions of Windows support a different set of batch-commands)
You should incorporate the build-number in the script as an Environment Variable –
use either the “built-in”
%BUILD_NUMBER% parameter or set your own format with
the Formatted Version-Number Plugin .
If you do need to edit that ‘CS’ file, I suggest using either Perl or PowerShell.