Reputation: 2202
I have a Jenkinsfile that contains a step that deploys to production only when the build happens on the master branch. On pull requests, all the steps except the 'deploy' step happen. My problem is that builds are not kicked off automatically upon commits to master. How to kick off both master and pull request builds automatically?
Here is the crux of the Jenkinsfile:
pipeline {
agent { label "aws-build-agent" }
stages {
stage('scm') {
steps {
checkout scm
}
}
stage('build') {
steps {
sh './.cicd/build.sh'
}
}
stage('deploy') {
when { branch 'master' }
steps {
withCredentials(
[
sshUserPrivateKey(
credentialsId: "my-deploy-key",
keyFileVariable: 'RSA_PRIVATE_KEY_FILE'
)
]
) {
sh './.cicd/deploy.sh'
}
}
}
}
}
My Jenkins configuration looks like this:
Upvotes: 1
Views: 311
Reputation: 2202
This turns out to be a false alarm. Make sure your GitHub webhook is sending push events as well as pull request events to Jenkins.
Upvotes: 1