PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 14, 2022

[FIXED] How to send Cutomised output through RUNDECK

 August 14, 2022     email, output, push-notification, rundeck     No comments   

Issue

I have set my rundeck-config.groovy in my config folder and this is included in my profile file as well.

My Groovy file:

grails.mail.default.from="pavan@gmail.com" grails {  mail {host = "smtp.gmail.com"   username = "pavan@gmail.com"    port = 587    password = "ghsdkexgbnsowmdsu"    props =["mail.smtp.starttls.enable":"true", "mail.smtp.port":587, "mail.smtp.auth":"true"]  }}

when i run my RUNDECK job i am recieving email notification, but the email i recieve has all the details, logs, commands used, even code which i dont want the recipent to see

i want to customise it and show only the output result in message body.

example: Checking Health of a server

url = "curl -kv https://vn2-lpgdmt-capp99.rno.vzon.com:8990/health/check"

in the output i only want to show as

https://vn2-lpgdmt-capp99.rno.vzon.com:8990/health/check = Status:200 ok

kindly help, what plugins i might have to add or anything

thank you in advance


Solution

You can use a custom template with your email notification that prints the output using ${logouput.data} to print the output, I leave an example:

<joblist>
  <job>
    <context>
      <options preserveOrder='true'>
        <option name='myurl' value='http://www.google.com' />
      </options>
    </context>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>322beb61-c701-4758-b58f-55da63953dee</id>
    <loglevel>INFO</loglevel>
    <name>CheckStatusExample</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <notification>
      <onsuccess>
        <email attachLog='true' attachLogInline='true' recipients='devopsteam@example.net' subject='Success!' />
      </onsuccess>
    </notification>
    <notifyAvgDurationThreshold />
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[echo "@option.myurl@=$(curl --write-out %{http_code} --silent --output /dev/null @option.myurl@)"]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
    </sequence>
    <uuid>322beb61-c701-4758-b58f-55da63953dee</uuid>
  </job>
</joblist>

With this HTML template:

<html>
    <head>
        <title>my template</title>
    </head>
    <body>
        <p>Data: ${logoutput.data}</p>
    </body>
</html>

Here the result on Rundeck, and here on the email inbox.



Answered By - MegaDrive68k
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing