Send e-mail notification from jenkins when warning occurs in ms-build - msbuild

I am using jenkins as my CI server for my .Net based project. I am using MS-Build plugin to build project from jenkins. It is working as expected, it sends an email when build gets failed. Now I also want jenkins to send email when build has warning in it. I could not find any plugin which provides this functionality out of box.
So I tried to use "Extended Email Notification", "Console Output Parsing" plugins. But it does not give me expected behaviour. Currently what I have acheived is sending a mail when warning occured. I mark build as unstable using "Console output parsing" plugin and send email using e-mail notification. But e-mail does not have details about warnings.
I came across few articles where it says we can use groovy script or jelly script and "Extended Email Notification" plugin to send details. But I don't how to fetch details of warning from parsing plugin. Can someone point me to correct resources or guide me to acheive this?

Look for
https://wiki.jenkins-ci.org/display/JENKINS/Text-finder+Plugin mark Build as "unstable" by parsing of log files. You can run downstream Jobs(if you have) also after "unstable" builds --> see job config. Status "unstable" is the "gray area" in Jenkins but has yellow color.
https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin sends E-Mails also for "unstable" builds with text extracted from build log files.

Jenkins is based on the assumption that a specific build (or "run") can either be "good" or "bad", hence the two-color scheme - there is no "gray area" for that matter.
Having said that, there are plugins to allow for a third state of "unstable",
which is also supported by the triggering mechanism.
Take for example the Text-finder Plugin or the Log Parser Plugin -
both will allow you to search keywords in files you specify and use that to downgrade a 'successful' build
to 'unstable' or a 'failed'.

Related

Notarize process for macos application not working

I have developed an application for MacOS. I am including notarization process as part of its distribution. I have followed all the steps and I have run:
xcrun altool --notarize-app --primary-bundle-id "${APP_BUNDLE_ID}" --username "${APPLE_DEV_ID}" --password "${DEV_APP_SPECIFIC_PASSWORD}" --file "${DMG_PATH}"
Then I check notarization progress using:
xcrun altool --notarization-info "${notarize_uuid}" -u "${APPLE_DEV_ID}" -p "${DEV_APP_SPECIFIC_PASSWORD}
Output of it is:
RequestUUID: =<Request>
Date: 2019-05-26 09:40:34 +0000
Status: success
LogFileURL: <Log file>
Status Code: 0
Status Message: Package Approved =~ success ]]
Then I launch staple command:
xcrun stapler staple -v <dmg file>
It also ends with success:
The staple and validate action worked!
However when I extract the .app file and run:
spctl --assess --verbose ./macos/MyApp.app
./macos/MyApp.app/: accepted
According to the docs I have read it should say something like: “source=Notarized Developer ID”, right?
I am running this on MacOS Mojave 10.14.5
What am I missing??
Could someone help me?
Thanks in advance
In case someone faces the same problem I will post the solution to this:
First of all you must staple .app file not the dmg. This means you must extract the binary and staple it
Also in order to check if application has been notarized, in
`System Preferences - Security and Privacy`
Option Allow apps downloaded from: must have Apple Store and identifier developers option checked
Hope this helps
Both the app and the dmg may be notarized and stapled, seperately, one after the other. Try doing that and the error should go away.
Short answer
It could be due to an RPATH referencing a path outside the App bundle. Removing this RPATH would resolve the issue.
Inspecting log files
You can find extra information about the rejection (after trying to launch the blocked app) in the Console.app. Note that you should open the Console.app, before trying to open your blocked app, otherwise not all messages may be logged. You should look for process XprotectService in the logs of your device (i.e. choose your device in the left side bar of the Console.app). If the RPATH is indeed the problem, you should find a record like this:
XprotectService: [com.apple.xprotect:xprotect] File /path/to/your/executable/or/library failed on rPathCmd /rpath/causing/the/problem (rpath resolved to: (path not found), bundleURL: /path/to/your/bundle.app)
Inspecting these log files may give you a key to solve other issues too.
Note that I received the following information from an Apple engineer:
Gatekeeper does not inform users via UI about the specifics of the
error, though it is in the logs for developers to look at. The
notarization process is purely about a detecting malicious software
and does not replicate Gatekeeper enforcement. You still need to get
software notarized and test with Gatekeeper.
We are looking to provide better tooling for developers in the future
to pre-flight some of these common errors.
Contact Apple
If you are not able to solve your issue with the above information, you may want to contact Apple itself using the Feedback Assistant. They do not respond very quickly (~1-2 weeks), but the answers are rather to the point.

How to notify failure of ddl,dml scripts through jenkins?

We have configured a job to execute the .ddl & .dml files through jenkins.
We want to get notified when some code inside a dml or ddl file throws an error.
Can we do this through jenkins plugins. If Yes which plugin & how?
There are multiple approaches. Depending how you run the scripts, Jenkins will fail the build if there are non zero exit code.
Another appproach we use is Log Praser plugin https://wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin . You can look for specific error string and fail with messsage. Then integrate this with Failure Cause Management plugin. It can given quick diagnostic message to the end user.

Failed to integrate Bugzilla Testopia with Jenkins with the aid of Testopia Plugin - cannot execute any iterative build step

I’m trying to integrate Bugzilla Testopia with Jenkins with the aid of the Testopia Plugin for Jenkins.
The general configuration is probably fine as the connection between Testopia and Jenkins is well established (Jenkins log says: ‘Connecting to Testopia to retrieve automated test cases’ and no error occurs then). However I’m unable to retrieve any information concerning Test Runs/Test Cases etc. from Testopia.
Moreover I cannot perform any of ‘Iterative Test Build Steps’. If I want to ‘Execute Shell’ in ‘Iterative Test Build Steps’ with Testopia Plugin no operation is carried out (even if I try: echo 12345 etc.). If I use ‘Single Test Build Steps‘ then shell command is executed.
My goal is to retrieve test class name from Testopia (it is stored in Testopia Test Case’s field - Automation/Scripts ) and then run maven build from Jenkins with this class name set as the parameter. Afterwards depending on the Jenkins build success or failure status I’d like to update the Test Case Status in Testopia.
How to fetch any information from Testopia into Jenkins?
Why any of ‘Iterative Test Build Steps’ is not executed?
Any clues? - Testopia Plugin site example wasn't too helpful for me.
Both Bugzilla and Jenkins are hosted on the same Ubuntu 14.04. I've got the latest stable versions of Jenkins, Bugzilla and Testopia.
Thanks in advance,
M.
EDIT:
Well this debugging does not work for me. I added a new log recorder with the 'ALL' level chosen and I cannot see any additional log neither in job's console output nor in the newly created logger output.
Maybe sth is wrong with my Testopia installation? Some more details concerning my configuration:
I've got Testopia installed on the same machine (as Jenkins) and usually I access it through: http://'ip_address'/bugzilla
- in Testopia plugin configuration my URL to Testopia installation is: http://'ip_address'/bugzilla/xmlrpc.cgi
- I've got only one bugzilla account - these admin's credentials I use in Jenkins
- sometimes in Jenkins I can see a warning concerning improper reverse proxy configuraiton - maybe it has sth to do with the problem
After job execution all Testopia's fields are 0 - Run Id, Build Id etc. - which obviously indicates that no information was successfully retrieved from Testopia.
Any ideas how to check why I cannot retrieve any information from Testopia?
EDIT 2:
In the meantime I think I've found a clue in the jenkins.log file in jenkins installation directory:
Exceptions like these occur:
INFO: TESTOPIA_TEST_SUITE_3 #13 main build action completed: SUCCESS
org.apache.xmlrpc.XmlRpcException: The requested method 'TestRun.get' was not found.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
...
org.apache.xmlrpc.XmlRpcException: The requested method 'TestRun.get_test_cases' was not found.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
Shall I insert the full stacktrace?
It looks like that plugin logs a fair amount of information, though not all of it to the build console output itself.
To debug further, you could try adding a new log recorder for the logger jenkins.plugins.testopia (with log level "all"), run a build, then refresh the web page for the newly-created log recorder to see the output.
You should at least see "Filtering for automated test cases" after connection, information about each test case found, and then log output for each iterative build step as it's run on each test case.
I got the similiar problem when I use python xmlrpc to commnicate with my bugzilla-testopia server.
I chekc the error code and find XMLRPC.pm under my bugzilla install location : "./WebService/Server/XMLRPC.pm".
I know the error was thrown by this sub function, which checks login status and forward to modules where the moduel.function must be in PUBLIC_METHODS:
sub handle_login {
...
if (none { $_ eq $method } $class->PUBLIC_METHODS) {
ThrowCodeError('unknown_method', { method => $full_method });
}
...
}
I don't know why but TestCase.get could not be found in PUBLIC_METHODS, so I just marked them as comment and then it works. You can do this quick way to make sure your client setting is correct. Then you should solve the "PUBLIC_METHODS" problem next.

automate, unattended or silent installation of a software

I have a software. It has GUI setup for windows and CLI install.sh for linux. On execution it asks user to accept license and on acceptance it asks for installation location, key, server ip, port, and a couple more option one after the other. I want to make the installation unattended so that the user double click a file and the next step is software installed. Any suggestions, thanks in advance.
The answer depends on what InstallShield project type you are using. I highly suggest Basic MSI. InstallScript custom actions are OK but don't use an InstallScript or InstallScript MSI project type.
Assuming the above, you create Secure Custom Public Properties so they can be passed at the command line. You also create custom dialogs so that the values can be entered during an interactive installation. Then you create validation custom actions that can guard against bad data in both scenarios. Finally you use the properties in Registry, INI, XML et al system changes so that they can be applied where needed for your application.
Your silent install then looks like:
msiexec /I foo.msi /qn INSTALLDIR=C:\FOO KEY=12345 SERVERIP=10.0.0.1
PORT=12345 /l*v install.log
Also be sure to understand the concept that properties aren't persisted automatically by MSI. You'll need some AppSearch/System Searches to retrieve the stored values for reuse during upgrade / patch / repair scenarios.
What you need is called Silent mode. Check your installation system's manual for this keyword.
Many installation systems support it - I can recommend you to use NSIS (/SILENT parameter) or Inno Setup (/SILENT, /VERYSILENT) if you did not started with creating your setup yet.
These are free (open source) installation systems and they are really powerful.
Be careful with this feature - many users are confused when they click the application icon and nothing happens (no window opens).
Ok I did this using expect tool (free). Here install.sh is the file I want to execute automatically and send are my options in response to the questions it asks during installation. Let me know if any problem following this.
!/usr/local/bin/expect
spawn "./install.sh"
set timeout 2
expect {WARNING: It is strongly recommended that you install RVS as root. Do you wish to run the installer as root [Y/n]}
send "Y\r"
send "xxxxxx\r"
expect {Press enter to read the License Agreement:}
send "ENTER\r"
expect {Do you accept the License Agreement [y/N]?}
send "y\r"
expect {Where do you want to install the tools [/usr/local/pkg/RVS/v3.1a]?}
send "ENTER\r"
expect {Where do you want to create links for tools [/usr/local/bin]?}
send "ENTER\r"
expect {Where do you want to create links for libraries [usr/local/lib]}
send "ENTER\r"
expect {Which license type do you wish to use [N/f/a]?}
send "f\r"
expect {IP address:}
send "1.1.1.1\r"
expect {Port:}
send "33\r"
expect {SERVERKEY}
send "xxxxxxxxxxxx\r"
expect {Do you want to install support for GNAT Pro {6.0, 6.1, 6.4} (You need a GNAT Pro license in order to use this feature) [y/N]?}
send "y\r"
expect {Proceed with the installation [Y/n]?}
send "y\r"
spawn "rvsinfo"
interact

How to get the currently logged in windows user with NAnt

I have a NAnt script that does a build and deployment of an ASP.Net application.
This lives on a remote machine that many people log into to perform builds.
(this is not automated for various reasons that are irrelevant)
Upon success or failure of the Nant script, I have an email being sent out to a team distribution list, stating that the build was successful or failed.
I would like to be able to list the name of the user who logged into the remote machine to run the build script in the text of the email.
Is this possible in NAnt?
I am using the standard NAnt <mail> task to do the email.
Check environment::get-user-name() function. It gets the user name of the person who started the current thread (nant process).
<mail
...
subject="Build run by ${environment::get-user-name()}"
...
</mail>