简体   繁体   中英

Jenkins problems - how to access global variables in MSBuild file and how to send mail when a condition gets passed

  1. For some reason I have to access Jenkins global environment variables like BUILD ID, etc. in my MSBuild file but I don't know how to do that.

  2. After running my NUnit project I create a specific report, a pdf file, but there may be times when this file does not get generated(like when there is no data to show) so I have to check whether this report exists or not and if yes, then I have to attach it in a mail and send to some guys. I am using Email-ext plugin of Jenkins but I am not sure how to check for this condition.

What do you suggest I do for these problems?

Thanks in advance.

  1. Don't know how Jenkins works, but there should be some way to pass additional command line parameters. To pass Jenkins global variable add /p: switch into the MSBuild command line. Let's say JenkinsVersion is global variable in Jenkins. You can pass it into the MSBuild with /p:MsBuildJenkinsVariable=JenkinsVersion . MsBuild $(MsBuildJenkinsVariable) property now should be filled with JenkinsVersion.

  2. I know you want to set condition in Jenkins somehow. If it is not possible to do it in Jenkins, you can do it using MSbuild script. I'm using MSBuild.ExtensionPack.Communication.Email MSBuild task to send notification e-mails. Set Condition property of the Email task to send e-mail when report file doesn't exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM