Groovy Subversion Hook Scripts - windows

I'd like to write some Subversion (SVN) hook scripts in Groovy. The SVN server will be running on windows, and according to the SVN book:
you would need to supply a program whose basename is the name of the hook and whose extension is one of the special extensions recognized by Windows for executable programs, such as .exe for programs and .bat for batch files.
Apart from installing Groovy on the local machine, setting the GROOVY HOME env var, and adding %GROOVY_HOME%\bin to the PATH, what else do I need to do before SVN can execute Groovy hook scripts?
Thanks,
Don

You should make sure your groovy scripts are associated to grooovy with the correct parameters, in order for Windows to execute them with their options when double-clicking them.
Notice you must set that association in a way that allow groovy script to be run with parameters.
Anyway, seems like a good page on that very subject could help : Debugging Subversion Repository Hooks in Windows

If you're not doing it as Riduidel recommends, you have to create a batch file calling groovy, for a precommit hook, it would be called pre-commit.bat and will be called with the parameters
[1] REPOS-PATH (the path to this repository)
[2] TXN-NAME (the name of the txn about to be committed)
These have to be passed to your groovy script...

Related

Jenkins calls batch file which needs windows environment variables. Bat file is uneditable

Basically Jenkins is calling a bat file which is proprietary and does some compilation.
Calling the file directly from command prompt works fine. However when Jenkins calls the bat file it cannot find environment variables it needs and an error is thrown that the value is unknown.
I know if I could edit the bat file I could circumvent the issue, but the file is proprietary so that is not an option. Any thoughts?
Disclaimer: Been a while since I used it (and Jenkins).
Back in the day we did this with the EnvInject plugin. Worked quite well as far as I remember it.

Automatic Firefox build on Windows(Jenkins)

I am trying to create a job for Jenkins to automatically build Firefox on Windows machine.
Is it possible to create a script(.bat, .sh or python) which starts start-shell.bat and executes mach build command inside started shell window?
Create a new freestyle job and then configure it. After specifying where your source code repository is located in the SCM section. Add a Window Batch Build step and specify the workspace-relative path to your .bat file that in turn calls the commands you want.

How do I make Grails execute shell commands just before creating war file?

Let's say I want to do git pull origin master just before preparing a war file.
To do something before the war is packaged, use the "CreateWarStart" event, e.g. as described in this answer. To actually run the Git command, use can use Groovy's ability to execute commands as strings, e.g. 'git pull origin master'.execute() (see the docs here) or do it more programmatically with ProcessBuilder like you would in Java, and optionally wrapped in a shell script to abstract the details away from the web app code.

Running a buildscript.xml file from jenkins

I am new to Jenkins CI and i am trying to run my buildscript.xml file from jenkis in windows OS,
can someone help me how do i do it correctly? Alternatively i have a build.bat batch file too, if i execute it in command prompt like ">build.bat trunk head"
it invokes build script and starts the build.
how can i accomplish the same in jenkins?
Thanks in advance.
Create a new Freestyle job
Select your Source Code system (svn, git, etc)
Specify which repo to check out from, and into which folder, for example my_co
The checkout will be available in what's known as workspace, and you can reference it's absolute location with %WORKSPACE%\my_co anywhere in the build
Create Invoke Ant build step, and specify location of your buildscript.xml, relative to %WORKSPACE%, and optional which targets to execute.
OR
Create Execute Windows Batch Command build step, and call your batch file, again the location is relative to %WORKSPACE%

Set variable in properties file based on a choice build param

We are in the process of setting up a Jenkins CI server to handle all of our WebDriver tests. Ideally, I would like to have choice build parameters for our QA team to select the server to test (production, etc.) for each build. We have a properties file in place to handle this, so we only need to make changes to that file. Are there any plugins out there that can do what we are looking for?
You could just use a shell build step
echo $MY_BUILD_VAR > $WORKSPACE/somefile
sometimes a plugin is more than you need! (though EnvInject would help if you have a mixture of OSes to support (i.e. *nix and windows) as Windows runs batch files and *nix goes with shell... though the windows version is trivially different
echo %MY_BUILD_VAR% > %WORKSPACE%\somefile
Yes, EnvInject Plugin can read environment from a property file and make it available to the build.

Resources