I'm working on workflow-durable-task-step Jenkins plugin and I want to debug one of the tests of this plugin. To understand the problem I need to see Jenkins logs. By default INFO level logs are shown during tests, but I need FINE level.
How to show all possible logs for internal Jenkins process during mvn test command?
I've tried to run tests like mvn -Djava.util.logging.loglevel=FINEST test but this option changes log level for test itself but not Jenkins internal process. I mean if I write something like LOGGER.log(Level.FINE, "Hello world"); in the body of my test - it will be show but no logs with FINE level of Jenkins process started by my test will be displayed.
I think you are looking for ${JENKINS_URL}/log/levels
Documentation: Logger Configuration
Also see: Viewing Logs
Within your test add something like the following:
#Rule
public LoggerRule logs = new LoggerRule()
.recordPackage(YourClass.class, Level.FINE)
The LoggerRule ultimately is what you wanted
Related
In my JMeter setup, I have the following config in my Test Aggregate Report (named loadTestAggregate) in order to list all the erroring URLs in my load test :
When I run my JMeter test locally, this Test Aggregate Report correctly displays the results (as a .csv) and the URLs are displayed as required (i.e. the response code, response message and URL are all displayed).
I then set up this test to run via Jenkins (with the Performance plugin installed).
Below is the Jenkinsfile used to run this test via Jenkins;
sh "jmeter -Jjmeter.save.saveservice.url=true -n -t loadTest.jmx -JTest_Url=${env.TEST_URL} -l jmeter_results.jtl"
perfReport errorFailedThreshold: 5.00, sourceDataFiles:'loadTestAggregate.csv'
However, when the test is completed and I look in Jenkins via the Performance plugin, the URLs are not displayed.
All that's displayed is the following;
Is it possible to get these (erroring) URLs to be listed via the Jenkins Performance plugin?
If so, am I missing something here as my config for the Test Aggregate report works locally but not via Jenkins, so I can only presume that it's a Performance plugin issue.
Many thanks
They're "aggregate" charts per Sampler label
As a workaround you can change the Sampler label (HTTP Request) to the Sampler URL, it can be done via JSR223 PostProcessor and the following Groovy code:
prev.setSampleLabel(prev.getUrlAsString())
where prev stands for the previous SampleResult, see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information.
Demo:
I set up a Jenkins to integrate the JMeter script. Using the Freestyle project in Jenkins, I enabled "This project is parameterized" to set a String parameters for the Threads, Loop_Count and Think Time.
In .jmx file, I used the Function Parameters function to define those
variables, as shown below image:
User Defined Variable
In Jenkins, I configured the parameterization as shown below:
Set Parameterization
Command Line
However, when running the test for 40 users using the Build parameter in Jenkins, it looks like the # of threads/users are not correct that is being executed, the Samples that are being generated only 3 for most of the pages. Only the Homepage (which is the first page on the test) is only getting the correct # of Samples, but the rest of the URLS/pages are not correct. Below the actual output.
Output
Can you please help what might the causing this issue, I already checked the Jmeter script and jenkins config and appears to be correct but still I'm getting the issue. Thanks for the help.
Setting parameters in Jenkins itself is not sufficient to pass them to JMeter, you need to pass this parameterized value to JMeter startup script via -J command-line argument
-Jusers=%users%
End-to-end demo:
More information: Apache JMeter Properties Customization Guide
e.g. I have the following errors in jenkins.err.log. How can I make Jenkins email this type of errors to me?
caused by: com.microsoft.tfs.core.ws.runtime.exceptions.UnauthorizedException: Authorization failure connecting to 'http://vstsprodapp:8080/Services/v1.0/Registration.asmx' (authenticating as domain\user)
This isn't a feature that's built into Jenkins.
You could use whatever system you use for monitoring your servers, and check the logs on the Jenkins server for error messages.
There is also an idea suggested on the Jenkins wiki, which allows you to use a Groovy hook script to add a further Java logging handler to Jenkins. But again, even if you do this, you would still have to implement a custom solution to send notifications based on the log's contents.
From https://wiki.jenkins-ci.org/display/JENKINS/Logging:
Put the following Groovy script into a file called $JENKINS_HOME/init.groovy.d/extra_logging.groovy:
import java.util.logging.ConsoleHandler
import java.util.logging.LogManager
def logger = LogManager.getLogManager().getLogger("hudson.WebAppMain")
logger.addHandler (new ConsoleHandler())
This will just copy all log records generated by Jenkins and any plugins to the console.
How would you go about accessing contents of the build (console) log from within a running build script?
I have a deploy script that runs, logs into a series of servers and runs scripts on those servers. I need to obtain certain output from some of those remote scripts and use them later in the build process and also in the completion email.
You can do something like this in the Post Build section, but I don't think you can do it earlier in the job. With the groovy post build plugin you can get information from the console log:
if(manager.logContains("text to find")) {
do something
}
I'm a newbie to Jenkins, so perhaps it is a stupid question, but...
I'm trying to write a job that will compile my code on several UNIX nodes. I created a multi-configuration project, and add one slave to it.
The job itself is a shell that only does 'ls' and 'pwd'
The output is:
Started by user anonymous
Building on master in workspace C:\Program Files (x86)\Jenkins\workspace\Unix-third-party
Triggering Linux64
Linux64 completed with result SUCCESS
Finished: SUCCESS
But I can't see the output of the commends anywhere.
When I changed the matrix to use nodes instead of labels, I managed, to see the output, but I'm still not sure what I did.
A free-style project for the same node works with no problems.
Where do I find the output?
On your job page, you'll see a link called "default" if you have only one node/slave, or the node's name if you have more than one.
Click on that link, then click on a build and console output.
The way it works is:
-----------------config 1 -> build #X -> console output
/
Main Job build #X console output ---->
\-----------------config 2 -> build #X -> console output
What you are looking at is the console output for the main job, but this only contains trigger information. The actual output is contained in the config 1 and config 2 console outputs.
Comment if you need further clarification, and I'd be glad to help.
Btw, welcome to the world of Jenkins :-)
==========================================================================
EDIT:
The following URL should take you to yourc console output for a build where you've chosen "Label":
Substitute everything in <>.
http://<myserver>/job/<jobname>/label=<label>/<buildnumber>/console
Not sure if this will help you, however at work, to view our slave consoles, the following URL will work:
https://ci.(company).com/job/QA/job/[projectname]/13/script=loadtest1/console
I'd assume your system would be similar.
Alternatively, if i go to the main ci.(company).com/job/QA/job/[projectname]/
i can see the recent job on the left corner.
When selected that specific job, at the base of the screen is our configurations, which you select, then can view the console output of that specific job.
Viewing the main jenkins job will not output console logs from slaves.
I ran into this today, not sure what caused it, but I was able to get my build configs to show console logs and artifacts once more by deleting "builds" and "configurations" folders under "C:\Program Files (x86)\Jenkins\jobs\ProjectName".
Obviously, this also gets rid of your build history, but I just need the configs running again.