email-ext plugin + credentials plugin?

18 views
Skip to first unread message

Guy Matz

unread,
Mar 24, 2016, 4:40:55 PM3/24/16
to jenkins...@googlegroups.com
Hello!  I'm trying to pass some credentials (via the credentials plugin) to a pre-send script within the email-ext plugin . . .  however, the credentials are not showing up as environment vars . . .  anyone know how if these two plugins can work together?

Thanks a lot!
Guy

Slide

unread,
Mar 24, 2016, 4:47:33 PM3/24/16
to jenkins...@googlegroups.com

Email-ext doesn't have any direct support for the credentials plugin. I am looking at adding it for the SMTP credentials, but not specifically for what you are describing.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CABnTgtXpLxev4G-sjtJa4i_mLgH%3DJf60GBN0EUzjGR-nkc1tQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Guy Matz

unread,
Mar 24, 2016, 5:02:22 PM3/24/16
to jenkins...@googlegroups.com
Thanks for the reply!  Any workarounds you can recommend?

Slide

unread,
Mar 24, 2016, 6:11:16 PM3/24/16
to jenkins...@googlegroups.com
How are you specifying the credentials? I am not completely familiar with the credentials plugin, so I don't know how it makes things available to a job. If it does it via the environment, then they should be available in the pre-send script. Can you post your pre-send script and job config?

Guy Matz

unread,
Mar 25, 2016, 9:37:39 AM3/25/16
to jenkins...@googlegroups.com
Thanks, yes the credentials are supposed to be in the environment!  My presend script is creating a Jira ticket via REST API, so I have my jira user's username & password in credentials, and am defining them as JIRA_USERNAME & JIRA_PASSWORD, respectively.  I am then referencing them in the pre-send like so:

def createJiraTicket(String changelog) {

  jiraProject = 'Change Management System'
  jiraProjectCode = 'CMS'
  jiraUser = System.env['JIRA_USERNAME']
  jiraPassword = System.env['JIRA_PASSWORD']
  logger.println("Accessing Jira with user ${jiraUser}")  // jiraUser shows up as null
  //  This loop has been added for debugging.  Many other ENV vars are logged here,
  //  but not JIRA_USERNAME & JIRA_PASSWORD
  System.env.sort().each {
    logger.println(it)
  }
  .
  .
  .

I *am* able to use $JIRA_USERNAME & $JIRA_PASSWORD in a build step . . .

Any thoughts here would be greatly appreciated!!

Thanks a lot,
Guy


Slide

unread,
Mar 25, 2016, 10:25:17 AM3/25/16
to jenkins...@googlegroups.com
Can you try using build.buildVariables['JIRA_USERNAME']? Also, there are a couple of JIRA plugins that might do what you want.



Guy Matz

unread,
Mar 25, 2016, 11:39:32 AM3/25/16
to jenkins...@googlegroups.com
Hmm . . .  no, the build.buildVariables['JIRA_USERNAME'] showed up as null . . .  any other thoughts?

Thanks again,
Guy

P.S. - Thanks for the pointer to the Jira plugin.  That might work for another problem I have!

Slide

unread,
Mar 25, 2016, 11:44:35 AM3/25/16
to jenkins...@googlegroups.com
Can you print out what is in build.buildVariables? The other thing to try would be build.getEnvironment(listener)['JIRA_USERNAME']

Guy Matz

unread,
Mar 25, 2016, 12:14:52 PM3/25/16
to jenkins...@googlegroups.com
getEnvironment(listener) worked!!

Regarding buildVariables, this code:
logger.println("Build Variables Start: ")
  build.each {
    logger.println(it)
  }  
  logger.println("Build Variables End")

Produced:
Build Variables Start: 
deploy-sidecar-gold-gmatz-test #20
Build Variables End

Thanks again!!

Reply all
Reply to author
Forward
0 new messages