TeamCity doesn't seem to pick up build service messages - teamcity

I am trying to import code coverage statistics from Clover into Teamcity so that I can set build failures if the level falls too low.
I am trying to get Teamcity to read in statistics from the .bat build script, but I'm not having any luck. I've tried getting my script to print out different variations of service messages to stdout but teamcity doesn't pick them up.
The service messages aren't printed in the build log, nor can I see them in the "Reported Statistics Values" tab in Teamcity.
The below is a list of the different ways i've tried to get Teamcity to read the messages..
echo ##teamcity[enableServiceMessages]
##teamcity[enableServiceMessages]
##teamcity[buildStatisticValue key='CodeCoverageS' value='52']
echo ##teamcity[buildStatisticValue key='CodeCoverageS' value='50']
echo ##teamcity[buildStatisticValue key='CodeCoverageL' value='45']
echo ##teamcity[buildStatisticValue key='CodeCoverageAbsCTotal' value='888']
echo ##teamcity[buildStatisticValue key='KashCC' value='50']
echo ##teamcity[blahblah key='KashCC' value='50']
echo ##teamcity[setParameter name='ddd' value='fff']
##teamcity[blahblah key='KashCC' value='50']
##teamcity[key='KashCC' value='51']
##teamcity[buildStatisticValue key='CodeCoverageS' value='50']
Any help would be appreciated.
Thanks

So the answer was to print the ##teamcity statements in a separate build step.
Once that is done they are picked up in the "Reported Statistics Values" tab

Related

How to trigger gitlab ci when a comment like "test please" is written in merge request discussion?

I saw there are several ways to trigger the CI.
Even for merge requests
https://docs.gitlab.com/ee/ci/merge_request_pipelines/
What I want to do is to trigger a gitlab CI pipeline not for all merge request and not for all commits.
Only when someone comments:
'test please' or 'test gitlab' or some special keyword maybe defined by regex?
Is this possible?
That was requested in gitlab-org/gitlab-foss issue 39215, and shipped with 11.0
rspec:
script: ...
only:
variables:
- $CI_COMMIT_MESSAGE =~ /some-regexp/
You also have the following workaround for pipelines (windows cmd shell):
Process the job only if commit message doesn't contain [CI Release]
script:
- git show -s --format=%%B | findstr /C:"[CI Release]" >nul 2>&1 && (exit 0) || (set errorlevel=0)
- cd beUcb
- call mvn -N -Pver resources:resources
- REM ... rest of script ...

How in envoy show debugging info?

Working with envoy in laravel 5.7 I see in examples that echo command is used for debugging purpose.
But whe I write echo in my envoy file, like:
#setup
$server_login_user= 'lardeployer';
$timezone= 'Europe/Kiev';
$path= '/var/www/html/AppDir';
$current = $path . '/current';
$repo= 'git#bitbucket.org:myaccount/votes.git'';
$branch= 'master';
echo "Step # 01";
$writableDirs= [
'/storage/logs',
'/bootstrap/cache'
];
echo "Step # 02";
...
echo "Step # 03";
#endsetup
#servers(['production' => $server_login_user.'#NNN.NN.NN.N])
#task( 'clone', ['on'=>$on] )
...
running envoy script I do not see any echo messages in my console.
I see echo command mentioned in 5.0 version documentation : https://laravel.com/docs/5.0/envoy But that does not
work in my 5.7/5.8 apps. Is echo still supported in laravel ? Or is that some config option ?
Thanks!
if you are going to use echo you should use it inside tasks as mention on laravel too
You may access the options in your tasks via Blade's "echo" syntax.
You may also use if statements and loops within your tasks.
for more detail click here

add job number to the build number in the project

I am using shell script and need to add the jenkins job number which is running currently to the BUILD NUMBER of the ios project
I am using plistbuddy to fetch the build number. I have got both the build number and job number with me but i am unable to add them. It is showing me error again n again
Script is something like this:
echo "BUILD_NUMBER is = "$BUILD_NUMBER
OUTPUT = $(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" Abc-Info.plist)
OUTPUT1 = $((OUTPUT + BUILD_NUMBER))
echo "$OUTPUT1"
image
Please help me what am i doing wrong

How to fix failed tests count in teamcity for re-executed tests?

We are using TeamCity for Selenium tests execution with Specflow+Specrun, the problem is that TeamCity count re-executed tests.
For example if some test failed for first time he will be re-executed two times more, in teamcity we will see that three tests failed, but probably it was one test.
Also if first re-execution will fail, but other two will success, this will be reported in teamcity as two failed, one passed, but I need to be reported that only one test has been passed.
It is possible to configure this in TeamCity using service messages or something else?
UPDATED:
Based on answer we can gather logs using powershell script and change build status using teamcity service messages:
$path = Get-ChildItem %teamcity.build.checkoutDir%\ProjectFolder\bin\Remote\TestResults\specrun.log
$file = Get-content $path
$total = $file | select-string "Total:"
$passed = $file | select-string "Succeeded:"
$failed = $file | select-string "Failed:"
write-host $( "##teamcity[buildStatus text='Tests {0}, {1}, {2}']" -f $total, $passed, $failed )
TeamCity is behaving as expected. TeamCity reports what Testing Framework tells him. Roughly the process is:
Execute step that run tests.
Gather the output logs.
Extract stats: number of test executed, passed and failing.
Fail the build if tests fail if configured to do that.
You have to configure your Testing Framework (specflow+specrun in your case) to change the way it reports the re-execution. You should configure specflow to log the re-executions in a different way... if it can.
In general you should avoid re-execution of tests. The tests should work at the first attempt. They should prepare the state if needed, do their test, and clean the state.
The need of re-execution indicates probably some dependency with the other tests. Something like:
Test 001: Search for user Foo1. (FAILS)
Test 002: Adds user Foo1. (OK)
Re-execution of Test 001: Search for user Foo1. (OK)
The correct way is that TEST001 does not have a dependency of TEST002, adds the user Foo1, test search and clean user Foo1.

Ansible Tower: Send e-mail if the project failed

I would like to get a e-mail when the project failed. So I've created a task at the end of the file wich sends me an e-mail. The problem is now that when a task failed also the hole project failed and the e-mail task wouldn't triggered.
Can somebody help me?
(I'm using Ansible Tower)
You should create a callback plugin where you can react on any situation like failed tasks.
Here is an example for a HipChat notification. It's not too hard to modify it to send email messages directly with a local or remote smtp.
Edit: Actually there is a mail callback plugin.
What if you send the mail from shell depending on the return code of ansible-playbook command ?
here's a sample shell script:
ANSIBLE_OUTPUT=$(ansible-playbook site.yml -K)
if [ $? != 0 ]; then
echo "playbook failed! OUTPUT: ${ANSIBLE_OUTPUT}" | mail -s "playbook results" your_email#your_email_domain
else
echo "playbook executed successfully!" | mail -s "playbook results" your_email#your_email_domain
fi
ansible tower itself provide this feature
you can create a notification template as described in
https://docs.ansible.com/ansible-tower/3.0/html/userguide/notifications.html#id1
than from notification option of workflow template, you can select this template on failure or success

Resources