# How to get pipeline script pull from bitbucket

**URL:** <https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472>\
**Category:** Ask a question\
**Tags:** pipeline\
**Created:** [August 23, 2022, 2:55pm UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472 "2022-08-23T14:55:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejoe89](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/ejoe89/32/4243_2.png) [@ejoe89](https://community.jenkins.io/u/ejoe89)\
**Post date:** [August 23, 2022, 2:55pm UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472/1 "2022-08-23T14:55:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/bpedersen2/32/367_2.png) [@bpedersen2](https://community.jenkins.io/u/bpedersen2)\
**Post date:** [August 23, 2022, 3:20pm UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472/2 "2022-08-23T15:20:18Z")

</div>

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 a`Jenkinsfile` 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.

---

<div class="post-metadata">

**Author:** ![ejoe89](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/ejoe89/32/4243_2.png) [@ejoe89](https://community.jenkins.io/u/ejoe89)\
**Post date:** [August 23, 2022, 3:54pm UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472/3 "2022-08-23T15:54:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [August 23, 2022, 9:45pm UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472/4 "2022-08-23T21:45:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ejoe89](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/ejoe89/32/4243_2.png) [@ejoe89](https://community.jenkins.io/u/ejoe89)\
**Post date:** [September 2, 2022, 3:17pm UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472/5 "2022-09-02T15:17:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [September 5, 2022, 7:43am UTC](https://community.jenkins.io/t/how-to-get-pipeline-script-pull-from-bitbucket/3472/6 "2022-09-05T07:43:57Z")

</div>

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.
