How to get pipeline script pull from bitbucket

I am setting up a jenkins pipeline project and need to tie it to bitbucket so that pull requests trigger a build. I’ve created a different/non-pipeline project that works. I have my code in the Pipeline Script section, but if I change it to Pipeline Script from SCM I lose the Pipeline script section.

I am sure I am missing something fairly basic. Can anyone point me to an article or give me any ideas?

That is expected, the Pipeline from SCM mode expects that the SCM has the code in Jenkinsfile at the toplevel (the path can be configured). So copy the script into aJenkinsfile and commit this. Then the next run should be able to see the Jenkinsfile. Make sure you trust anyone who can push changes for the Jenkinsfile.

1 Like

Ah, that makes sense. So I will copy the pipeline script into Jenkinsfile, push that to the root folder of the project, and then configure the SCM portion accordingly?

That’s the recommended way to go yes. Have everything in SCM all safe and sound. Plus then you can use multi branch pipelines and build MRs/branches/etc.

The other way to do it is look at the pipeline syntax generator on the sidebar of your pipeline and use a git step manually

So I have it working, thanks to your help. Though I noticed that I put the jenkinsfile in the dev branch.

So if I want dev branch to build and deploy to server A, and sandbox branch to go to Prod server, would I have two different jenkins files? Or one? And where should that go?

I’m not a Jenkins expert in any way, but that’s the way I would do it…
Or you could have the same Jenkinsfile with two different sets of variables.