Creating a calendar entry in jenkins using pre-email script

I am currently using jenkins version 1.617 with the latest editable email editor.

What we are trying to do is accept the changes from the assembly and put them in the meeting notification (calendar entry).

We are currently stuck with 8.5.3FP6 lotus notes.

Here are our variables in the plugin:

Project Recipient List = $SERVER_GROUP Content Type = HTML(text/html) Default Subject = $DEFAULT_SUBJECT Default Content = $DEFAULT_CONTENT Repo: myRepo Install Location: S:\Build\VAT - Visual Authoring Tool\SERVICELOGIQ \GM\VAT_${ENV, var="miniVersion"}\VAT_${ENV, var="releaseversion"}_SERVICELOGIQ [${ENV, var="BUILD_NUMBER"}] Change Log: ${CHANGES_SINCE_LAST_SUCCESS, reverse=true, showPaths=true} 

We are trying to use the following presend script:

 import javax.mail.Message import javax.mail.Message.RecipientType import javax.mail.Address import javax.mail.Multipart import javax.mail.BodyPart import javax.mail.internet.InternetAddress import javax.mail.internet.MimeMessage import javax.mail.Session import javax.mail.internet.InternetAddress import javax.mail.internet.MimeBodyPart import javax.mail.internet.MimeMessage import javax.mail.internet.MimeMultipart import javax.mail.util.ByteArrayDataSource import java.util.Date import java.util.Calendar import java.util.TimeZone import java.text.DateFormat import java.text.SimpleDateFormat import javax.activation.DataHandler msg.addHeaderLine("method=REQUEST"); msg.addHeaderLine("charset=UTF-8"); msg.addHeaderLine("component=VEVENT"); final Calendar cal = Calendar.getInstance(); cal.add(Calendar.HOUR, 1); final Date start = cal.getTime(); cal.add(Calendar.HOUR, 1); final Date end = cal.getTime(); SimpleDateFormat dateFmt = new SimpleDateFormat("yyyyMMdd'T'hhmmssZ"); String fmtStartDate = dateFmt.format(start); String fmtEndDate = dateFmt.format(end); String subject = msg.getSubject() Multipart multi = (Multipart)msg.getContent() BodyPart part = multi.getBodyPart(0) String body = part.getContent().toString() String from = " jenkins@ignore.com " Address[] toAddresses = msg.getAllRecipients() String to = toAddresses.each{ it.toString() }.join(",") String content = "BEGIN:VCALENDAR\n"+ "PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN\n"+ "VERSION:2.0\n" + "METHOD:REQUEST\n" + "BEGIN:VEVENT\n" + "ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:" + to + "\n" + "ORGANIZER:MAILTO:" + from + "\n" + "DTSTART:" + fmtStartDate + "\n" + "DTEND:" + fmtEndDate + "\n" + "LOCATION:Jenkins Build\n" + "TRANSP:OPAQUE\n" + "SEQUENCE:0\n" + "UID:040000008200E00074C5B7101A82E00800000000002FF466CE3AC5010000000000000000100\n" + " 000004377FE5C37984842BF9440448399EB02\n" + "DTSTAMP:20051206T120102Z\n" + "CATEGORIES:Meeting\n" + "DESCRIPTION:" + body + "\n\n" + "SUMMARY:" + subject + "\n" + "PRIORITY:5\n" + "CLASS:PUBLIC\n" + "BEGIN:VALARM\n" + "TRIGGER:PT1440M\n" + "ACTION:DISPLAY\n" + "DESCRIPTION:Reminder\n" + "END:VALARM\n" + "END:VEVENT\n" + "END:VCALENDAR"; // Create the message part MimeBodyPart messageBodyPart = new MimeBodyPart(); // Fill the message messageBodyPart.setHeader("Content-Class", "urn:content-classes:calendarmessage"); messageBodyPart.setHeader("Content-ID","calendar_message"); messageBodyPart.setDataHandler(new DataHandler( new ByteArrayDataSource(content, "text/calendar")));//very important // Create a Multipart MimeMultipart multipart = new MimeMultipart(); // Add part one multipart.addBodyPart(messageBodyPart); // Put parts in message msg.setContent(multipart); 

This is what we understand from this script, it looks like the script accepts an email that has already been created, parses the values ​​and changes them to a calendar entry. However, when we run this script, it creates a calendar entry, but it only gets the first line of text in the default content section for email.

Here is an example of a created letter:

 BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN VERSION:2.0 METHOD:REQUEST BEGIN:VEVENT ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:myemail ORGANIZER:MAILTO: jenkins@ignore.com DTSTART:20150716T123802-0400 DTEND:20150716T013802-0400 LOCATION:Jenkins Build TRANSP:OPAQUE SEQUENCE:0 UID:040000008200E00074C5B7101A82E00800000000002FF466CE3AC5010000000000000000100 000004377FE5C37984842BF9440448399EB02 DTSTAMP:20051206T120102Z CATEGORIES:Meeting DESCRIPTION:Check console output at http://usfhmtsapp09.na.global.mahle:8080/job/Test_Project_Sean2/77/ to view the results. Repo: http://usnomtsapp01/hg/hgweb.cgi/GM%20ServiceLogiq Install Location: S:\Build\VAT - Visual Authoring Tool\SERVICELOGIQ\GM\VAT_\VAT__SERVICELOGIQ [77] Change Log: Changes for Build #77 No changes SUMMARY:Test_Project_Sean2 Build Successful! PRIORITY:5 CLASS:PUBLIC BEGIN:VALARM TRIGGER:PT1440M ACTION:DISPLAY DESCRIPTION:Reminder END:VALARM END:VEVENT END:VCALENDAR 

Our actual meeting notification is displayed as follows:

Check the console output at http: // servername to view the results. With the attached email file above.

Note that the output string is the DEFAULT_CONTENT variable specified above.

We have already tried the following:

 def env = System.getenv() def version = env['CHANGES_SINCE_LAST_SUCCESS'] 

However, this returned a NULL value. I would appreciate any help we could solve to solve our problem.

+6
source share
1 answer

For several lines in the description in the calendar file, you need to put in escaped \ n instead of the actual lines of the new line.

0
source

All Articles