How to run script shell before building on Jenkins - maven

(Jenkins newb-newb-newbie here)
Hi there.
I have a Maven project, deployed on Jenkins . In this project, I have an integration test, which depends on a .Net server in order to be run correctly.
The problem is, when I'm trying to build my project on Jenkins, the integration test fails, because the .Net isn't launched...
I need to execute a shell script (for launhing the .Net server) before building my project.
So my question is : how can I launch a script of my project before building from Jenkins?

Theres a build step Execute Windows batch command which you could use to start your server.
You might have to use START to have it launched in a separate process, so your build continues without waiting for the server process to finish, and you might need to put in some delay in case your server needs some time to settle before your tests can run.
You might also need to kill your server after your tests are done, you might be able to use tasklistand taskkill in another Execute Windows batch command build step, and some batch magic to do this.

Related

Running gradle test tasks in Microsoft App-V5.1 virtualized environment

I'm very new to App-V, which is evaluated in my office.
I have a Selenium test suite written in JUnit5 and can launch it as gradle test task using gradle-wrapper. My final goal is to run this on App-V5.1 virtualized environment, similar as this question.
As followed the link which was mentioned the answer, I tried to launch cmd.exe within the App-V environment, and it seeded works. Then, I tried to do this:
./gradlew --no-daemon clean test
Then the testClasses phase works perfectly, but in the test phase, I got an error like:
Could not write standard input into: Gradle Worker 1.
java.io.IOException: The pipe is being closed
...
(Sorry I couldn't show you the actual error log due to security reason, but it is similar to this question.)
May I wrong something? What's the right way to launch a gradle test in App-V env?
Have you tried launching cmd.exe from within the virtual bubble? I find the best way to do this is to create a shortcut to cmd.exe during sequencing and use this to troubleshoot.
If your process works within the bubble, the solution may be as simple as allowing Local Interaction. Have a read here about that.

SVN commit using Jenkins

I recently created an automated process to run multi-step Maven builds for my organization. They now are looking to have the entire process automated using Jenkins. I have been able to successfully create branches, builds, change versions, etc., using Maven commands but I am having difficulty committing the version changes (1.0.1-Snapshot to 1.0.1-E1 for example) with Jenkins. I have tried using basic commands like:
SVN commit "Comments"
However, Jenkins does not seem to know what to do with these command lines in the "Execute Windows Batch File" Post Build option. I simply receive build failures caused by the batch file for "unknown reasons." I see the help desk I am working with has installed the Subversion plugin, but perhaps something else is missing. I know that when I use the command prompt locally I need to use something like this:
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"
/command:commit /path: /url:
However, Jenkins is hosted by a third party and I do not have direct access to the servers so I would not be able to implement that kind of path data. So I am now looking to see if I can run this, somehow, purely through Jenkins as my client requests.
Anyone have any success with SVN Commit to update version changes through Jenkins?
Thanks!
-Cameron
Why did you decide to run TortoiseProc via Jenkins? TortoiseProc is not the right tool for this task, use svn.exe client.
TortoiseProc can be used for TortoiseSVN's GUI automation, but this case is completely different to running Jenkins.

How to execute remote bat file using build step in TeamCity?

I have TeamCity installed on centos. I have only one Linux BuildAgent for now. My build configuration execute a maven script and using ant upload WAR artifact to Windows Server on FTP. After this step i have to execute BAT file on remote Windows Server. I read that i can do this using psexec/RemCom, but i can't understand how i can do this in TeamCity? Build Step or different Build Configuration should contain steps to execute psexec/RemCom or i can insert Build Step into existed Build Configuration?
Single build configuration could potentially consists of multiple build steps. Think of them as a actions you would like to do. So I suppose that right now you have a maven step in your build configuration. I would suggest you to add Command Line step, where you can do what ever you want -- it's like bash/batch script. You can put script contents directly to the build step, or you can write script and execute it.
But as you mentioned that you have CentOS, it could be you have to do extra configuration on the build agent for PsExec to be available.

How to set up a CI environment using jenkins, rvm and cucumber

I am new to CI and would like your thoughts and input on how to go about my problem. I would like to first start off that I have been wrestling with this for 2 days(and I don't have that much background in sys ad) so please play nice?(I am mainly a front-end web dev) :)
Basically my plan was to install jenkins then make a CI env with these steps:
poll for any changes to github
if there are, run the build script:
a. migrate the development and test dbs?(does that mean i have to put the config/database.yml in my repo?)
b. run cucumber
c. if all tests pass go to 3, else fail
run any rake setup stuff
run the server(deploy)
I have done some of the stuff by cheating:
in my local, i switch my rvm to the correct one i need(rvm use 1.8.7-p174#mygemset)
run jenkins(java -jar jenkins.war) so that it gets the RVM ruby as default
run spork in a separate terminal(because for some reason my cucumbers don't run without spork - that's another problem)
build the project manually by clicking Build
so basically, I want to automate these stuff. Maybe what I need is a set of steps to follow(general or specific, depending on your taste) so I can setup my CI up and running.
Keep in mind that my "cheats" won't do as I want to test different projects with different setups and the startup cheat just won't do. Currently, my project build was successful because all I did was to run cucumber(and all my cukes pass). I want it to be able to deploy after it passes so maybe some help there also? Thanks
Okay I will try and help you as best I can.
poll for any changes to github
This can be easily done with the Github Plugin located here
if there are, run the build script: a. migrate the development and test dbs?(does that mean i have to put the config/database.yml in my
repo?) b. run cucumber c. if all tests pass go to 3, else fail
Then all you would is run the build script you have configure in the in the build from
Select "Add Build Step" -> "Execute shell".
You can either do that which is probably what I would do because when you create build you want them to be portable so you can start up in new jenkins instances, so you dont have to setup your build machine, with build specific files.
Then you run your tests, if they fail the build should fail regardless here is some information on running ruby on rails tests. if you need to manually fail a build in a script based on a result usually exiting a script with non-zero will fail the build. If not continue and run your rake and deployment scripts.
Just a few notes on Jenkins it wont do everything for you but if you can do it manaually Jenkins can automate it. So anything you have setup running manually with a little bit of effort you can get up and running automated with Jenkins
Here is another answer you might find helpful in your general setup and ideology behind Jenkins.
Goodluck!

Having a shell script refer to XCode build paths

I have a shell script that runs lcov (test coverage) on an iOS project that I have Hudson. Hudson's copy of this project is derived from a Git repository. The way that I have set up now is that whenever the repo is updated or if someone manually builds the project in Hudson, Hudson would automatically run the app, and then run my shell script after the build is done. lcov can only be run after the app is not only built, but automatically run with some functional test tools. So, I cannot run the shell script as part of the build process, through XCode. It must be run after the app finishes building and running.
However, I would like to use this project in multiple Hudson jobs. Unfortunately, in each Hudson job, the iOS project is named differently. I would like to refer to the build path with some sort of environmental variable, but I don't know how to. Does anyone have any tips as to how to find that?
If I understand you correctly this is really a Hudson question. You can set "global variables" in your Hudson config and then invoke shell scripts, batch files, ant builds etc. You can also set them dynamically on each invocation of your Hudson job. Not sure exactly how to help you in your specific environment without more info.

Resources