TeamCity: Customize build failed error message (include it in email) - teamcity

We are using TeamCity to process hundreds of builds. We added a custom command line script which prints an error to console, and if the enviroment variable TEAMCITY_VERSION is set, then we print the error message in the format TeamCity understands:
Console.Out.WriteLine(
"##teamcity[message text='Custom Script failed.' errorDetails='" +
ex.Message + "' status='ERROR']");
Now, I see that the error is displayed in the build log, however, under the build details, we only see [13:00:25]Process exited with code 1, and in the email notification sent to developers that included changes in that build, only that line is sent.
Is it possible to send in the email, and include in the build details the error we actually print to the console?

There is some build script interaction available:
Console.Out.WriteLine(
"##teamcity[buildProblem text='Custom Script failed.' errorDetails='" +
ex.Message + "']");
And complete it with a buildStatus:
Console.Out.WriteLine(
"##teamcity[buildStatus text='{build.status.text} : Environment variable issue.' status='FAILURE']");
You can get more information about building script interaction on the official website:
When you will send the mail, if you have a specific routine which watch the build, you can get information easily using the available api.

Related

Using vsce via command line in Github Action throws Invalid publisher name error

We have an existing extension that is already in the VS Code market place.
I'm trying to automate publishing by using Github Actions and executing this command...
vsce publish -p ${{ secrets.VSCODE_PAT }}
When the command executes I'm getting this error:
ERROR Invalid publisher name 'Wilderness Labs'. Expected the
identifier of a publisher, not its human-friendly name.
The vscode documentation doesn't really help in this situation. Any ideas/suggestions?
The publisher name MUST NOT be a string literal with spaces. As mentioned by #Lex it needs to be a something like WildernessLabs or wilderness-labs or whatever it is for your own organisation.

Error: command "bash" failed with no error message?

I am using terraform on my Mac system, and terraform apply results with below error
Error: command "bash" failed with no error message
on ssm.tf line 7, in data "external" "ssm-dynamic-general":
7: data "external" "ssm-dynamic-general" {
However there is nothing wrong in ssm.tf file, same runs perfectly fine in my another system.
Can some one please let me know what i am missing here?
You might have done what I accidentally did: not follow the external program protocol:
https://www.terraform.io/docs/providers/external/data_source.html#external-program-protocol
In my particular case, I failed to send the errors that were coming from my program to standard error. Instead, those errors were going to standard out.
That's why Terraform wasn't able to report on those errors.
So if you send any and all errors from your program to standard error using > &2, you should be able to see those errors when you run terraform plan.

Sonarqube : The 'report' parameter is missing

I am using MSBuild. I have Java 8 installed.
I am running the following commands:
SonarQube.Scanner.MSBuild.exe begin /k:"ABC" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="8b839xxxxxxxxxxxxxxxxxxxxxxx6b00125bf92" /d:sonar.verbose=true
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" /t:rebuild
SonarQube.Scanner.MSBuild.exe end /d:sonar.login="8b839xxxxxxxxxxxxxxxxxxxxxxx6b00125bf92"
The last step fails:
ERROR: Error during SonarQube Scanner execution
ERROR: The 'report' parameter is missing
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
12:53:21.909 Creating a summary markdown file...
12:53:21.918 Post-processing failed. Exit code: 1
The MSBuild version is greater than 14.
Java 8 is properly installed. Documentation indicates that Java 8 is adequate.
Any idea on what could be wrong?
Where do I add the -X switch? I tried on all 3 statements
Update :I installed Java SDK 9. Still same issue.
Update :With verbose logging and using /n naming parameter:
INFO: Analysis report generated in 992ms, dir size=4 MB
INFO: Analysis reports compressed in 549ms, zip size=1 MB
INFO: Analysis report generated in C:\ABC\.sonarqube\out\.sonar\scanner-report
DEBUG: Upload report
DEBUG: POST 400 http://localhost:9000/api/ce/submit?projectKey=ABC | time=1023ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 54.833s
INFO: Final Memory: 51M/170M
INFO: ------------------------------------------------------------------------
DEBUG: Execution getVersion
DEBUG: Execution stop
ERROR: Error during SonarQube Scanner execution
ERROR: The 'report' parameter is missing
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Process returned exit code 1
The SonarQube Scanner did not complete successfully
Creating a summary markdown file...
Post-processing failed. Exit code: 1
I've struggled the same problem with SonarQube and I've finally found a solution:
You need to restart sonar service after using evaluation token.
Please note this isn't the answer, however I feel this feedback is valuable to getting this question answered.
I can reproduce this issue in POSTMan with a POST request to:
http://localhost:9000/api/ce/submit?projectKey=myProjectKey
This returns
{
"errors": [
{
"msg": "The 'report' parameter is missing"
}
]
}
You can get a similar error by removing the projectKey query parameter. I tried adding a report query parameter and received the same error:
http://localhost:9000/api/ce/submit?projectKey=brian3016&report=report
Given this, I feel there is a problem with their code. It should have included a report parameter when creating the POST request, but it failed to do so.
Verbose output seems to have changed from using the -X switch to /d:sonar.verbose=true. E.G.
SonarScanner.MSBuild.exe begin /k:"myProjectKey" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="myLogin" /d:sonar.verbose=true
Note the verbose logging didn't give me any valuable insight.
(Also note that the documentation currently says to use SonarQube.Scanner.MSBuild.exe, but the verbose logger told me to switch to SonarScanner.MSBuild.exe)
SO...how we we report this issue to someone that can fix it? Their documentation says to go to Stackoverflow. So here we are.
I thought it may have been an issue with a project. So I created a new project with nothing other than the startup template Console Application. Same error.
In my case SonarQube 7.9.1 (deployed with Helm to Kubernetes cluster) was missing temp directory /opt/sonarqube/temp/tc/work/Tomcat/localhost/ROOT after Helm rollback. No idea what happened to it.
Logfile /opt/sonarqube/logs/web.log inside SonarQube pod had this error:
2021.02.02 06:57:03 WARN web[AXdZ6l6MParQCncJACv3][o.s.s.w.ServletRequest] Can't read file part for parameter report
java.io.IOException: The temporary upload location [/opt/sonarqube/temp/tc/work/Tomcat/localhost/ROOT] is not valid
The fix was to exec into pod and create the missing directory. Would like to know the reason though...
The issue is with the sonar service starting up.
First try to stop the SonarStart.bat by using Ctrl+c, and then try to open localhost:9000 ( or whichever port you configured sonar server).
If it is still opening then go to task manager and search for wrapper.exe service and stop the service. If no service is found then go to:
Task manager>Details> and stop all java.exe process.
Note: If you running many Java applications, right-click the java.exe and choose goto service, and stop only those java.exe that belongs to AppX deployment.services
Now start sonarstart.bat as administrator..
today i face the same error when using jenkins to scanner the code.
get the error when POST /api/ce/submit and get 400 code by add the sonar.verbose=true
i use the below step to check reason
first to restart the sonarqube => failed
check the report file size by using "du -sh" get 108m and DB server support 1G => failed
login the sonar-qube server and check the access.log, web.log and another log, finally find the error reason " Processing of multipart/form-data request failed. No space left on device", so i check the server by command "df -h", some devices are used 100% => so i remove some no-using file and fix it!!!
check if you have enough memory
ex: free -m
In my case I had to upgrade memory.

Issue using User defined parameter in Build Feature teamcity?

I have template which have two build steps:
Maven
Command line
Command line steps sets current datetime in variable which i want to use in Build Feature.
I am getting proper Current datetime as follows via Command Line step:
#!/bin/bash
export current_build_date_format="+%%d%%m%%Y_%%H%%M%%S"
export current_build_date="$(date $current_build_date_format)"
##teamcity[setParameter name='current_build_date' value='$current_build_date']
When i am trying to refer it in Build Feature, its not able to identify parameter via "%current_build_date%"
It shows paramter as undefined in Configuration Parameter section
Anything missing? I have defined that parameter via command line, how will teamcity features use that
Parameter error:
Error while reading user defined parameter first:
Initialization
[05:42:27][Initialization] - Build Details Validator
[05:42:27][ Build Details Validator] Error: Conversion = 'm'
[05:42:27][Initialization] Build validation failed
You need to echo TeamCity service message to let TeamCity parse and use it, e.g.:
echo "##teamcity[setParameter name='current_build_date' value='$current_build_date']"

PhantomJS failing on remote ajax field check

I developed a script to complete & submit a remote form via PhantomJS (version 2.1). For testing I built a local approximation of the remote form which included an ajax field check upon input (so, you enter an email address in the email field, and after a second it checks to see if it's a valid input). My phantom script fills out the fields, waits a few seconds for an error to be thrown, and then carries on to submit the form if everything looks okay. This all worked just fine with everything running on localhost.
However, as soon as I switch to making the call to the remote webpage (which is a third-party site; I have no access to make changes to it), it fails when the remote page performs the ajax check on fields. I have the following onResourceError function:
page.onResourceError = function(resourceError) {
system.stderr.writeLine('= onResourceError()');
system.stderr.writeLine(' - unable to load url: "' + resourceError.url + '"');
system.stderr.writeLine(' - error code: ' + resourceError.errorCode + ', description: ' + resourceError.errorString );
};
...and if I run the following line (in a Windows command prompt):
phantomjs.exe form-process.js "https://contact.site.com/auth/form?params=that&are=always&the=same" "clarence#email.com"
I get the following error:
https://contact.site.com/ajax/email-check?email=clarence#email.com"
- error code: 302,
- description: Error downloading "https://contact.site.com/ajax/email-check?email=clarence#email.com"
- server replied: Bad request
I am running this from a local environment but with no SSL certificate installed, so I assumed (based on the description of the 302 error code: the requested operation is invalid for this protocol) that it was a cross-protocol issue. But running the phantomJS line with any combination of --ssl-protocol=any, --ignore-ssl-errors=yes or --web-security=false yields the same results.
I may be misunderstanding these modes for phantomJS, but I assumed that --ssl-protocol=any would dismiss this issue, but would I still need to have a local SSL cert to get this to work? Or is there another issue here?

Resources