I'm using multijob plugin, Where I have created a Job using it and configured 2 Job in it as shown here:
I've configured to run both job sequentially. But while I do build Its execution order is
Job 1
Job 2
Then Again
Job 2
Job 1
I want it to be configure, the execution should be only one time Job 1 and Job 2. How do I configure here ?
Steps to trigger multiple job using Multi Job Plug In:
In your first job that is "Rcontact_Dashboard_testSuite" click on Add build step
Then select trigger/call builds o other project
on Projects to build field just type "Rcontact_Main_TestSuite" that is your second job.
Then build the first job
This will run your first job after that it will trigger your second job.
Hop this will solve your issue. let me know your feedback.
Below configuration working for me.
I have used Multijob Plugin and configured my both job in different phases as shown Here
Related
My Jenkins build hangs between build and post-build steps.
The console output shows there is a 6-minute wait (but I've seen waits of up to one hour):
10:53:26 BUILD FAILED in 1m 7s
10:53:26 4 actionable tasks: 4 executed
10:53:26 Build step 'Invoke Gradle script' changed build result to FAILURE
10:53:26 Build step 'Invoke Gradle script' marked build as failure
11:09:29 [CucumberReport] Using Cucumber Reports version 4.9.0
I found this and this questions that have similar issues, and they say the solution is setting -DSoftKillWaitSeconds=0 in jenkins.xml.
However, I need a way to set the option for particular jobs only, without messing with global Jenkins settings (I wouldn't want to mess with other projects).
EDIT:
When I manually abort the job, before the [CucumberReport] step, Cucumber reports are still generated.
I also checked Abort the build if it's stuck checkbox in Build Environment options, with Time-out strategy set to No Activity (Timeout seconds = 2).
When I build the project with these settings, the build will fail with "Aborted after 0 seconds" shown in Build History, as before, but the console output will be the same. (Nothing changes, Cucumber Reports will be generated but after a certain timeout).
It is not possible to select a job-specific value for SoftKillWaitSeconds (the value is derived from the Jenkins core at a point where the job name is not known).
My recommendation is to fix the abort handling in your job itself, so it will not depend on a "soft kill timeout". If you're running on a Unix-ish system, you can ensure this by running your job in a new process group (set -m in bash) and (for example) setting up a proper exit trap.
We are using the Build-timeout plugin to kill stuck jobs with timeout strategy set to No Activity or Absolute. For me, this is a good approach when you are using freestyle projects.
The reason why your build is "Aborted after 0 seconds" is that most likely there are unfinished child processes.
From documentation:
Because Java only allows threads to be interrupted at a set of fixed
locations, depending on how a build hangs, the abort operation might
not take effect. For example,
if Jenkins is waiting for child processes to complete, it can abort
right away.
if Jenkins is stuck in an infinite loop, it can never be
aborted.
if Jenkins is doing a network or file I/O within the Java VM
(such as lengthy file copy or SVN update), it cannot be aborted.
You could try the absolute timeout strategy. You can define a global variable, so that you do not repeat the timeout value in jobs:
Go to "Manage Jenkins" > "Configure System".
Check "Environment variables" in "Global properties".
Add an environment variable name="GLOBAL_TIMEOUT_MINUTES" value="20".
Go to a configuration page of a project.
Check "Abort the build if it's stuck" in "Build Environment".
Select "Absolute" for "Time-out strategy". Of course, also applicable to other strategies.
Set "${GLOBAL_TIMEOUT_MINUTES}" for "Timeout".
Set timeout action "Abort the build".
If this is not working, you could try to look in the logs https://your-jenkins-server/log or in a thread dump.
The hanging may be caused by new/old version of a plugin. Try to find what are the unfinished child processes. Try to disable post-build actions one by one to find the one that may be the cause of the issue.
You can see https://superuser.com/questions/1401879/debugging-what-happens-when-a-jenkins-build-unexpectedly-pauses-or-hangs
I have created some test cases and placed them in testng.xml file. I have created a build.xml(ant build) file which is running without any errors. now my task is that i need to run all my test cases through jenkins integration tool using ant build.
I have installed jenkins on my ubuntu system.
what are the further configurations like creating a job, scheduling tasks ???
The next step is to create a job. Then set the workspace of that job ( usually your project directory), set the scheduler to run whenever you want. For the syntax of the scheduler (chronos) you have a help button.
For example:
#midnight will run every midnight
* H/2 * * * will run every 2 hours.
After that set the build command and save. You're done! Try a manual build by pressing on "build now" to see if you have configuration mistakes, if you have correct them and done.
I kill jenkins process and started again. After the restart, all the jobs are disappeard. However in my jenkins directory under "jobs" I can see all the job folder still exist.
/app/jenkins
Look like somehow I need to tell the jenkins to pickup all the configuration from existing directory. But not sure how to do.
Any help would be appreciated.
It was a mistake on my part. The reason Jenkins didn't pick up the old jobs is that upon restart, I did not have my JENKINS_HOME environment variable defined. Thus Jenkins didn't pick up the old jobs.
export JENKINS_HOME=/app/jenkins
I have a Spring Batch application with a Task Scheduler based on this implementation.
Basically, during development in Eclipse, I execute the following maven goal:
mvn clean install exec:java
to execute the batch application. The above command executes my MainApp class which has a static main class that loads the Application context file and from there, Spring takes control. During development, this is not a problem since I need to see the logs in the console. But during integration in my Jenkins server I am encountering a problem with this setup.
In Jenkins, when I try to build the application using the above goal, the build never finishes because it holds on to the console. I need the build to finish so that the downstream projects are also built. My question is, how do I tell Jenkins to ignore the console and proceed to the next build process? In short I want to start the batch application on the background without it holding on to the console so that my build can continue.
What I have tried so far:
I tried changing the goals such that exec:java will be called as a Post Step. Still it does not work. What are other methods in which to perform this?
I have job A that is building after developers commit code (SCM change). I also have job B that should be run once a day (by cron) and it should use the artifact that results from execution of build A.
Is it possible to configure Hudson job B to run on cron and before it really executes it should trigger execution of job A?
Job A shouldn't know anything about job B.
Perhaps a better way to do what you want. Have Job A mark the files that Job B wants as Artifacts (preserves them between builds). Then have Job B on it's cron schedule and when it runs, it uses the Copy Artifact Plugin to retrieve the required files from Job A. Then Job B can do it's build operation.
If you have a maven project (which is also a good way to pass artifacts from one build to another), the M2-extra-steps jenkins plugin (now deprecated and integrated into the M2 plugin I think) allows you to do that:
As a pre-build step, add 'build another project', check 'lock until build is done' and that should do what you need.
If you do have a freestyle project - I'm not sure. If the equivalent does not exist you might be able to come up with something based on locks and latches.
All that said, why do you want to rebuild A before B if it hasn't changed since the last SCM commit?