Thanks Anish for the reply.

while runing the script provided ,i ended up in

Error when executing always post condition:
java.lang.NoSuchMethodError: No such DSL method 'jiraNewIssue' found among 
steps 

i am new bee.I tried debugging but could not trace back



pipeline {
     agent any
    stages {
        stage('build') {
            steps {
                echo "build steps"
            }
        }
        stage('testing') {
            steps {
                echo "unit testing"
            }
        }
    }


  post {
        always {
            echo 'I will always say Hello again!'
            create_newjira_issue()
              script {
                        def mailRecipients = 'x...@gmail.com'
                        emailext body: '${SCRIPT, template="email.groovy"}',
                        mimeType: 'text/html',
                        subject: "[Jenkins] ",
                        to: "${mailRecipients}",
                        replyTo: "${mailRecipients}"
                        
                            }
            
        }
    }
}
void create_newjira_issue() {
    node {
      stage('JIRA') {
        def NewJiraIssue = [fields: [project: [key: 'JIT'],
            summary: 'Build Failed : Summary.',
            description: 'Description of JIRA ticket ',
            issuetype: [id: '3']]]

    response = jiraNewIssue issue: NewJiraIssue, site: 'THAT CAN BE SET IN 
JENKINS CONFIGURATION OR CAN DIRECTLY WRITE HERE'

    echo response.successful.toString()
    echo response.data.toString()
    }
  }
}


On Monday, 11 November 2019 21:27:33 UTC+5:30, Anish Choudhary wrote:
>
> Hi Touseef,
>
> As excepted JIRA issue can be created in pipeline projects, using 
> Jenkinsfile (assuming you are known of Jenkinsfile [pipeline steps written 
> in groovy language]). Anyway we can use the following syntax (code Snippet) 
> to implement it :
>
> //--------------------------------------------------------------------------------------------------
>
> pipeline {     agent any
>
>     stages {        stage('build') {            steps {                echo 
> "build steps"            }        }
>         stage('testing') {            steps {                echo "unit 
> testing"            }        }
>     }
> } 
>
>  post {        success {            emailext (                to: 
> 'bangar...@gmail.com <javascript:>',                mimeType: 'text/html',    
>             subject: "*************** As excepted***********",                
> body: "************** As excepted **************"            )        }       
>  failure {            emailext (                to: 'bangar...@gmail.com 
> <javascript:>',                mimeType: 'text/html',                subject: 
> "*************** As excepted***********",                body: 
> "************** As excepted **************"            )
>             create_newjira_issue()    }}
>
> void create_newjira_issue() {    node {      stage('JIRA') {        def 
> NewJiraIssue = [fields: [project: [key: 'PROJETC_NAME : can be taken from 
> JIRA website'],            summary: 'Build Failed : Summary.',            
> description: 'Description of JIRA ticket ',            issuetype: [id: 
> 'PROJECT ID : can get using JIRA API']]]    response = jiraNewIssue issue: 
> NewJiraIssue, site: 'THAT CAN BE SET IN JENKINS CONFIGURATION OR CAN DIRECTLY 
> WRITE HERE'    echo response.successful.toString()    echo 
> response.data.toString()    }  }}
> //--------------------------------------------------------------------------------------------------
>
> Note : To get the JIRA fields you should have admin access of JIRA else get 
> above information from JIRA admin.
>
>
> Regards,
> Anish Choudhary
>
>
> On Mon, Nov 11, 2019 at 10:01 AM touseef <tousee...@gmail.com 
> <javascript:>> wrote:
>
>> I want to Create Jira Issue on Build Failure through *Jenkins pipeline*.I 
>> am able to achive this help in freestyle projects.
>> Can anyone help me in integrating the create jira issue in jira 
>> automatically via pipeline syntax when jenkins build fails.
>>
>>
>>
>> -- 
>> 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 jenkins...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/e3fbcd13-9e9d-4eab-b3b9-222e9864d6b6%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/e3fbcd13-9e9d-4eab-b3b9-222e9864d6b6%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/54397b05-f2b0-415a-8b02-34a996425c84%40googlegroups.com.

Reply via email to