jenkins-docs/simple-java-maven-app

java.lang.NoSuchMethodError: No such DSL method 'triggers' found among steps

Opened this issue · 1 comments

I want to create pull_request automatically in bit bucket based on build success condtion.
However after appending PR jenkinsfile code it is throwing error mention in subject line.
triggers method not found.

Please help to write Jenkinsfile DSL groovy code for how to create new PR everytime if build success .

Following is my Jenkinsfile code.

def gitUrl(){

 return "${env.GIT_URL}";

}

def gitSourcebranch(){
return env.SOURCE_BRANCH;
}

def gitTargetbranch(){
return env.TARGET_BRANCH;
}

def environment(){
return env.ENVIRONMENTS; // this is env variable create in jenkins job

}

def branch(){
return env.BRANCH;
}

def UserEmail(){
return env.git_conf_email;
}

def UserName(){
return env.git_conf_user;
}

def Gitlab_Pass(){
return env.GITLAB_PASS;
}

def ansibleVaultCredentials() {

 if (env.VAULT_PASS != null) // created in credential in secret file with id vault_secure
       return env.VAULT_PASS;
 else
      return '';

}

stage('git_checkout'){
node('dockercon2'){
checkout([$class: 'GitSCM',
branches: [[name: "${gitSourcebranch()}"]],
doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'],
[$class: 'PerBuildTag'], [$class: 'WipeWorkspace']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'bitbucket_glone_cred',
name: 'origin', refspec: "+refs/heads/${env.SOURCE_BRANCH}:refs/remotes/origin/${env.SOURCE_BRANCH}",
url: "${gitUrl()}"]]])
stage ('git_buildhost'){
git branch: "${gitSourcebranch()}",
credentialsId: 'bitbucket_glone_cred', url: "${gitUrl()}"
withCredentials([usernamePassword(credentialsId: 'bitbucket_glone_cred',
passwordVariable: 'bit_pass', usernameVariable: 'bit_user')]){
sh "git config credential.username ${UserName()}"
sh "git config credential.helper ${Gitlab_Pass()}"
sh "git config --global user.email ${UserEmail()}"
sh "git config --global user.name ${UserName()}"
//sh "set +x /bin/sh -c "echo ${ansibleVaultCredentials()}>vault_passwd.txt""
sh "set +x; echo ${ansibleVaultCredentials()} >> vault_passwd.txt"
sh "echo pass"
sh "cat vault_passwd.txt"
sh "ansible-vault decrypt --vault-password-file vault_passwd.txt test2.sh && sh test2.sh"
}//stage git_buildhost closer
// } // Closing paranthesis for withCredential
} // Closin paranthesis for node
}// This parenthesis for Shttps_gitlba_clone_crede

stage('PR'){
if (currentBuild.result == null || currentBuild.result == 'SUCCESS')
triggers{
bitbucketPullRequestCreatedAction()
}
scm {
git {
remote {
url("${gitUrl()}")
}
}
steps {
shell('figlet START pull request created')
}
}
}
}//first

The issue tracker is used to track issues. Your request seems to be a request for help, not a report of an issue or improvement.

Please use the mailing lists and the chat channels for questions.