jenkins performacne plugin with pipeline project,Compare with specific build - performance

I have created jenkins pipeline project where running jmeter test.
here i am not able to find option /attribute which can be passed/added to perfReport command with which i can comparr current run with specific past build number.
current perfreport options i do see are
perfReport filterRegex: '', relativeFailedThresholdNegative: 1.2, relativeFailedThresholdPositive: 1.89, relativeUnstableThresholdNegative: 1.8, relativeUnstableThresholdPositive: 1.5, sourceDataFiles: 'results.csv'

You need to add the following stanza to your pipeline:
modeEvaluation: true, nthBuildNumber: 1
change this 1 to the build number you would like compare the current result to.
More information:
Jenkins Pipeline Syntax
How to Use the Jenkins Performance Plugin
How to Build Reports with Peformance Plugin

Related

How to detect if a Gradle build is running on TeamCity?

Some log messages in my build scripts are only relevant when the Gradle build is running on TeamCity. How do detect programmatically if the Gradle build is running on TeamCity or not?
This can be done using environment variables corresponding to TeamCity's server build parameters, quote:
Environment variable name
Description
TEAMCITY_VERSION
The version of the TeamCity server. This property can be used to determine if the build is run within TeamCity.
To do it in a Gradle script, method java.lang.System#getenv(java.lang.String) can be used:
boolean isOnTeamCity = System.getenv("TEAMCITY_VERSION") != null

Jenkins and SonarQube for Pipeline Gating without using the SonarQube Jenkins Plugin in bash

We have a build that runs SonarQube from Jenkins using a bash script, and we want to get the results of the tests back in the Jenkins pipeline so we can prevent merges on fail. We are using v2 of Jenkins, but it is an old version that doesn't support the SonarQube Jenkins plugin, and upgrading Jenkins isn't something we can accomplish in our sprint.
Is there is a way to get the results to gate our pipeline with what we have? At the moment this is how we're running SonarQube from Jenkins in OpenShift.
dotnet build
~/.dotnet/tools/coverlet "./bin/Debug/netcoreapp3.1/AppTests.dll" --target "dotnet" --targetargs 'test . --no-build --logger "trx;LogFileName=TestResults.trx" --logger "xunit;LogFileName=TestResults.xml" --results-directory ../BuildReports/UnitTests' -f opencover -o ./BuildReports/Coverage/coverage
dotnet build-server shutdown
~/.dotnet/tools/dotnet-sonarscanner begin /k:${APP_NAME} /n:${APP_NAME} /d:sonar.host.url=${SONAR_URL} /d:sonar.cs.opencover.reportsPaths="./BuildReports/Coverage/coverage.opencover.xml" /d:sonar.exclusions="**/Migrations/*" /d:sonar.coverage.exclusions="**Tests*.cs","**/Migrations/*","**/Program.cs" /d:sonar.cpd.exclusions="**/Migrations/*" /d:sonar.cs.vstest.reportsPaths="./BuildReports/UnitTests/TestResults.trx" /d:sonar.cs.nunit.reportsPaths="./BuildReports/UnitTests/TestResults.xml"
dotnet build -v n
~/.dotnet/tools/dotnet-sonarscanner end
dotnet build-server shutdown
Install the Build Breaker plugin on the SonarQube server. And enable it for the project you are scanning -- to do this go to Project Settings on the SonarQube server. You may need server level and project level Administrative rights for doing this.
Now the Sonar Scanner will check for the quality gate status after doing the code analysis. In case the quality gate fails, the scanner returns with a non-zero status code that can be used to mark the build as “failed”.
https://github.com/adnovum/sonar-build-breaker#sonarqube-build-breaker-plugin
In case you don't have control over what gets installed on the SonarQube server, then you may write a bash script to use the curl command to hit web API of your SonarQube server to first find if the analysis report has been processed by the SonarQube server and then the quality gate status of the code analysis just concluded.
For the documentation of the web API, see http://<sonarqube-server-host>/web_api.

Reduce Travis-CI building time for Gradle

I've started a new project of SprintBoot and Kotlin and I wanted to use Travis-CI as my CI server.
I also wanted to use codecov to collect the reports about my code coverage
Everything seems to work perfectly beside one thing, My project currently is an empty SpringBoot project that contains (and no tests) and the build itself takes up to 2m (mostly due to the time it takes to install Gradle).
I checked on their site and saw some optimizations to the build, but they're looked to early for this stage of the project (e.g. parallel tests execution).
Am I missing something? is 2m is the baseline for Travis-CI building time?
My current configurations for Travis :
# This enables the 'defaults' to test java applications:
language: java
# We can specify a list of JDKs to be used for testing
# A list of available JDKs in Trusty can be seed in:
# https://docs.travis-ci.com/user/reference/xenial/#jvm-clojure-groovy-java-scala-support
jdk:
- openjdk11
before_script:
# makes sure that gradle commands can be executed on build
- chmod +x gradlew
script:
# Makes sure that gradle can be executed.
- ./gradlew check
# Generates the reports for codecov
- ./gradlew jacocoTestReport
# This is to enable CodeCov's coverage
# If a build is successful, the code is submitted for coverage analysis
after_success:
- bash <(curl -s https://codecov.io/bash)
You'll want to cache to improve speeds of your build on Travis. Gradle has a dedicated guide on building on Travis: https://guides.gradle.org/executing-gradle-builds-on-travisci/
For caching, scroll down to Enable caching of downloaded artifacts

TeamCity - Get Build Server Log | Currently Build

I am using TeamCity build server for my CI process. I have a scenario, where i need to compare my previous and current build log and check for warnings in the code ad if the warnings count in the current is greater than the previous build, we have to fail the build.
I have two build steps namely:
For MS build
A powershell script to compare the builds ( previous build and current build)
I understand we can get the build information using the TeamCity API which is http:// /httpAuth/downloadBuildLog.html?BuildId=<< current build id >>
Is there anyway to get the build log while the build is in running state, and pass on to my second step ?

Jenkins Build Pipeline plugin with empty ${PIPELINE_VERSION}

I'm using Build Pipeline plugin in Jenkins.
I've set a job and configured it to create the delivery pipeline version. The result will be something like: 3.0.0_r119723_b5
I can see the jobs are displayed with the correct build titles (the pipeline version).
After that, I need to pass this variable to Maven, but the ${PIPELINE_VERSION} always arrives empty.
clean install -Dapplication.version=${PIPELINE_VERSION}
I've already tried to remove the "{" and "}" but it didn't work.
Any thoughts?
Apparentely this is a bug in Maven Project plugin. I've updated both Maven Project and Delivery Pipeline plugins and now the ${PIPELINE_VERSION} works.

Resources