How to send custom url from jenkins to email? - jenkins

I need to send my report url in content to mail from jenkins after build in editable email notification. Can any one please help on this?

Please configure the editable email notification build steps as below :
Project Recipient List: someone#example.com,anyone#example.com
(NOTE: This is a comma-separated list of email addresses that should receive emails)
Project Reply-To List: replyto#example.com,plsreplyto#example.com (NOTE: This is a comma-separated list of email addresses that should receive emails)
Content Type: HTML (text/html)
Default Subject: This is subject of email
Default Content: (NOTE: here you can write HTML Code to add links and other elements) below is the example
<b>Build Status: </b>$BUILD_STATUS <br><br>
<b>Console Output of Build #$BUILD_NUMBER : </b> <br>
<span style="display:block; padding: 3px 10px; border-radius: 5px;white-space: pre">
$BUILD_LOG
</span>
<br>
<b>Build URL : </b>$BUILD_URL<br>
<b>Report URL :</b> https://myreport_url.com
Now, click on Advance Settings
In "Triggers"
Triggers: click "Add Trigger", select the condition when you want to trigger the email based on build status. for example, if you want to trigger an email for all the builds then select "Always"
Now, remove the "Developers" from "Sent To" (In the same trigger configuration as shown below)
In the same configuration, ensure below configuration
Recipient List should be empty
Reply-To List : $PROJECT_DEFAULT_REPLYTO
Content Type : Select Project Content Type
Subject : $PROJECT_DEFAULT_SUBJECT
Content : $PROJECT_DEFAULT_CONTENT
You can always click (?) next to each field to understand its role and what values it expects.

Related

How can you configure Jenkins Pipeline so you can automatically send an email with a custom body?

I'm trying to have Jenkins pipeline automatically send an email, but with a custom body. The pipeline is called from a web application by a button, so I was thinking about having a text box there to write the desired message before the button is pressed. However, I don't know how this chunk of text can get sent to Jenkins.
Right now the pipeline is sending emails through emailext, with the body message hardcoded. I know I can pass data from a web app to Jenkins with the Build With Parameters API, which I'm currently using for a Username and Password field, but sending a whole email message as a parameter sounds incorrect.
emailext (
subject: "---subject---",
body: """Hi,
This is the hardcoded message that I would the user to have flexibility to create themselves
""",
to: "---list of recipients---"
)
You can also use something like this, where you could add REGEX and EXCERPT to customize your mail content
emailext(
to: "email_list",
subject: "Subject",
body: '''$BUILD_URL
${BUILD_LOG_REGEX, regex="DRYRUN.*DRYRUN.*DRYRUN",maxMatches=1, showTruncatedLines=false}
${BUILD_LOG_EXCERPT, start="EMAIL CONTENT:",end="END OF EMAIL CONTENT"}''',
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
Here is a function ready to be executed, you can also add an attachment.
Adapt to your needs.
def sendMail() {
def body = """
<html>
<body>
<p>Hello</p>
<p><img src="cid:screenshot.jpg" alt="screenshot"/></p>
<ul>
<li><strong>Jenkins Build URL:</strong> ${env.BUILD_URL}</li>
</ul>
</body>
</html>
"""
emailext(to: recipient, subject: 'SUCCESS : ' + subject, body: body, mimeType: 'text/html', attachmentsPattern: 'screenshot.jpg')
}
Ist thing you job needs a parameter MAILTEST and then you can just this parameter in the body of the email just like coldplayer proposed.
Honestley for I used https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin
because the default trigger support only a kind of token as parameter on the rest interface.

Mandrill "Send A Copy Of Every Email To This Address" : CC or BCC?

On the 'Sending Defaults' settings page of mandrill, there is a setting 'Send A Copy Of Every Email To This Address' field.
I would like to know 2 things: Is this sent using 'to', 'CC' or 'BCC', and if I send to X users, do I receive X emails or just 1?
I assume 'BCC' and '1' are the answers, but mandrill's test suite doesnt actually send emails, so this function isn't triggered and I cannot find any documentation on this.

Quickbooks Online - How to implement SSO with intuit in Ruby/Rails

I was able to connect with to Intuit using the Minimul/QboApi gem and get the "Connect to Quickbooks" button working with oauth2 based on the example provided on Github. However neither the gem nor the samples show how to implement single sign on with Intuit. In the example provided by Minimul, the Connect To Quickbooks button is produced by intuit's javascript found at https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.5.js
and a setup script and the tag . The tag appears to have been deprecated. Or at least, it doesn't appear to do anything other than produce the button with the right text and logo on it.
But bottom line, I have been unable to find any documentation on the ipp.anywhere.js package, and not even sure if i's meant to used with oauth2 since it's not mentioned anywhere. I believe that the connect to intuit button does the right things, but the guidelines seem pretty strict about what that the button needs to say the right thing and have th eright logo or they will reject it in the store. They also seem to suggest that users are much more likely to try something if an SSO with Intuit workflow is enabled. Any help appreciated.
After some further work, I figured out a solution that can create a 'log in with Inuit button' , although it's a bit of a javascript hack. First, I determined that the only thing I really needed to change was the button image. In other respects the code behind ` works fine for either a "login with intuit" or "connect to intuit work flow" . The only problem is the button image.
Here is the code (adapted from Minimul/QboApi) to get access and oauth2 refresh tokens via a "Connect to Quickbooks" button.
Setup in the controller code in login or sessions controller:
def new
#app_center = QboApi::APP_CENTER_BASE # "https://appcenter.intuit.com"
state= SecureRandom.uuid.to_s
intuit_id = ENV["CLIENT_ID"]
intuit_secret = ENV["CLIENT_SECRET"]
client = Rack::OAuth2::Client.new(
identifier: intuit_id,
secret: intuit_secret,
redirect_uri: ENV["OAUTH_REDIRECT_URL"],
uthorization_endpoint:"https://appcenter.intuit.com/connect/oauth2",
token_endpoint: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",
response_type: "code"
)
#make sure to include at least "openid profile email"
#in the scope to you can retrieve user info.
#uri = client.authorization_uri(scope: 'com.intuit.quickbooks.accounting openid profile email phone address', state: state)
end
Here is the code required to generate the button on the view. (The view needs to load jquery as well in order for the script to work.)
<script type="text/javascript" src="<%= #app_center %>/Content/IA/intuit.ipp.anywhere-1.3.5.js">
</script>
<script>
intuit.ipp.anywhere.setup({
grantUrl: "<%== #uri %>",
datasources: {
quickbooks: true,
payments: false
}
});
</script>
<div>
<ipp:connecttointuit></ipp:connecttointuit>
This code produces the following html on the page delivered to the client:
<ipp:connecttointuit>
Connect with QuickBooks
</ipp:connecttointuit>
This code produces a button with the Connect with QuickBooks image, and an event handler inside intuit.ipp.anywhere-1.3.5.js attaches itself to the click event.
The problem is that the button is styled by the class=intuitPlatformConnectButton attribute inside the generated <a> tag, so if you want a "login with intuit button instead of a connect with intuit button the class on the anchor needs to be changed to class='intuitPlatformLoginButtonHorizontal' but still needs to attach to the event handler defined for <ipp:connecttointuit>. The best solution that doesn't require mucking with intuit.ipp.anywhere is to create the connect button and hide it, and then create another tag styled with class=intuitPlatformLoginButtonHorizontal whose click event calls click on the hidden connect button. I use AngularJs on my login page, so I handle the click with ng-click, but it could be done simply with jquery alone.
new.html.erb:
<div>
</div>
<div>
<ipp:connecttointuit id="connectToIntuit" ng-hide="true">< </ipp:connecttointuit>
</div>
and the controller code:
$scope.intuit_login = function() {
let el = angular.element("#connectToIntuit:first-child")
el[0].firstChild.click();
}
This will result in a redirect upon authentication to the supplied redirect url, where you can use openid to get the user credentials.

How to add more than 1000 email address using mail_to

Currently i have the below code in index view
<div id = "GetEmails"><%= mail_to "xyz#gmail.com" do %><strong>Send Mail</strong><% end %></div>
In runtime, I am updating the value of mailto: which consists of more than 1000
+email address
Now, when I click on "Send Mail", outlook is not getting opened by copying all the email address in To: field
But, if the number of email address are < 100, the on click of "Send Mail" I am able to copy all the email address in To: filed
Manually, I am able to copy more than 3000 email address.
How do I get copy all the email address in To line by clicking "Send Mail".
The mailto:(as any other URL) has a character limit for the URL, it's vary from browser to browser, or from E-Mail client to E-Mail client.
Please try to use JS.
You could have a HTML element with data attribute where all emails would be stored and then try this:
<div id="my-mails-storing-element-id" data-mails="person1#domain.com, person2#domain.com,person3#domain.com"></div>
var mailsDom = document.getElementById("my-mails-storing-element-id")
location.href = mailto:mailsDom.dataset.mails;
But it would be better if you create separate action in your controller to get those emails. Then you just need to make AJAX call to get mails data.
I hope it'd help you. Please let me now if it worked (I've tried with Mailspring mail client and it worked)

Google Form/Sheet - Skip blank email google script

This is a similar question to this link, but slightly different:
Skipping blank emails in Google Apps Script Mail Merge
I have a form/sheet set up that, when the users fills out the form, it generates a receipt email (does not contain the form contents as some receipts do) that is then sent to the recipient. However when the user leaves this field blank I get a form trigger error, which is understandable why the script didn't finish. I am trying to figure out how to keep the script from attempting to send an email when the recipient/email field is blank. Unfortunately, making the email field required on the form is not an option since, oddly, not everyone would have an email address (if this were an option I would certainly just require an email address to be entered).
I have tried the following code snippet based on the link provided above.
// Send Email to recipient(s) declared above in #var sendEmail
if (e.values[11] != null) {
var sendEmail = e.values[11]; //email field column
var subject = "subject message";
var body = "body message";
MailApp.sendEmail(sendEmail, subject, body, {
name: "Community Home Health Care",
body: body,
noReply: true,
})
I have also tried instead of
(e.values[11] != null)
using
(e.values[11] != "")
The remaining code I have omitted (goes above what I have shown) simply takes the form field responses and generates a document converted to a PDF which works as expected. The email section also works, just trying to eliminate the failed script emails I get occasionally.
Thanks
First is an assumption that 12 items are passed (0 through 11) and the email is the last item to be passed. If that is the case, then test that the item is defined with:
if(typeof e.values[11] !== 'undefined')
If you are using the Mail Merge Tutorial linked to in the post you linked to, and using the getRowsData() function to get your form responses, you should be able to use the Header of the column containing the email address such as e.values.emailAddress and get:
if(typeof e.values.emailAddress !== 'undefined')
This may vary based on how your data is defined.

Resources