Validating Email Parameter

The Jenkins project announced an unresolved security vulnerability affecting the current version of this plugin (why?):

master: Build Status

Plugin;
- performs e-mail validation
- prevents sending e-mails except the specified domain.
- prevents typo
- user1@jenkins.io user2@jenkins.io user3@jenkins.io --> user1 user2 user3 can be written and performs specific validation. E-mail address will be generated automatically in the build process.

Parameter Definition

  • Default Value : Specifies the default value of the field, which allows the user to save typing the actual value.

  • Domain : Permitted domain name for sending mail.

Validation

External Email : If checked, Sending mail is allowed outside the set domain name.

External Email : false

Build

  • Invalid Email

  • Valid Email

You can copy that code directly into the pipeline block in your Jenkinsfile

pipeline {
   agent any

    parameters {
        email defaultValue: 'sezai.can', description: 'Email address', domain: 'sahibinden.com', externalEmail: true, name: 'EMAIL'
    }

   stages {
      stage('Email') {
         steps {
            echo "${params.EMAIL}"
         }
      }
   }
}