Reputation: 1150
I'm trying to implement a new Jenkins pipeline using Jenkinsfile.
The GIT repository does not have a Jenkinsfile on every branch, just under a specific one (as I'm currently building CI stuff for a legacy repository).
Jenkins Pipeline is created with following configuration:
**
Jenkinsfile
The webhook is automatically created in my Bitbucket repository, and builds are triggered just fine (when I push modification on the branch with the Jenkinsfile
).
However, Jenkins does not checkout the commit sent in the hook (different HASH from another branch). As a result, build crashes as Jenkinsfiles
do not exist on another branches (and will never exist on old legacy branches).
> git fetch --tags --force --progress -- http://mybitbucket:port/scm/vs/myrepo.git +refs/heads/*:refs/remotes/myrepo/* # timeout=10
Seen branch in repository myrepo/old-branch-a
Seen branch in repository myrepo/old-branch-b
...
Seen 40 remote branches
> git show-ref --tags -d # timeout=10
Checking out Revision 0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76 (myrepo/old-branch-x)
> git config core.sparsecheckout # timeout=10
> git checkout -f 0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76 # timeout=10
Commit message: "my commit message"
First time build. Skipping changelog.
Posting build status of INPROGRESS to mybitbucket for commit id [0a781a1bd4ad194aae911ce26d1ec4cd1e73dd76] and ref 'null'
ERROR: /var/jenkins_home/workspace/myrepo@script/Jenkinsfile not found
Technical context:
I cannot understand why this revision is chosen over the one sent in the hook.
Thanks a lot for your help!
Upvotes: 2
Views: 2565
Reputation: 1150
I was misled all along.
Turn out that I need to use Multibranch pipelines
instead of regular ones. It works well and create webhooks automatically as desired (using the right Scan Multibranch Pipeline Triggers
configuration).
I'm still frustrated by the behaviour of regular pipelines, which makes no sense to me and seems poorly documented.
Upvotes: 1