I have a multibranch job in my jenkins, what I have a webhook setup from my github to my jenkins that send every pull request changes and issue comments.
What I'm trying to do is let github send the pull request changes for indexing purposes, but don't run the job, unless the developer add comment 'test' in the comment on the github pull request.
This is my Jenkinsfile
,
pipeline {
agent { label 'mac' }
stages {
stage ('Check Build Cause') {
steps {
script {
def cause = currentBuild.buildCauses.shortDescription
echo "${cause}"
}
}
}
stage ('Test') {
when {
expression {
currentBuild.buildCauses.shortDescription == "[GitHub pull request comment]"
}
}
steps {
sh 'bundle exec fastlane test'
}
}
}
}
So I want if the trigger isn't GitHub pull request comment
, don't run anything. I've tried this but it doesn't work. I've tried print currentBuild.buildCauses.shortDescription
variable and it prints [GitHub pull request comment]
, but the job still won't run with my when expression
How can I do this? Thanks