<p>In case you're not using the Declarative Pipeline, you can avoid checking out from SCM by:</p>

<pre><code>node {
        skipDefaultCheckout()
        //...
}
</code></pre>

CC BY-SA 3.0
2017-10-06T11:36:36.077Z
Could you add a link to the documentation and explain more about skipDefaultCheckout()?
030
CC BY-SA 3.0
2017-10-06T12:05:29.417Z
I don't see any added value compared to existing answer, that's just a 'try this' with no explanation and not a good answer.
Tensibai
CC BY-SA 3.0
2017-11-23T13:53:26.597Z
This answer is fine as a supplement to the accepted answer - not everyone will be using the declarative Pipeline plugin, so this works for those using the procedural one.
RichVel
CC BY-SA 3.0
2017-10-06T09:37:29.337Z
2017-10-06T09:37:29.337Z
user3118604
<p>I think what you want to achieve is processing a webhook payload in a Jenkins job. Using bitbucket plugin won't be necessary and it is probably strongly designed to clone the repo.</p>

<p>I belive <a href="https://stackoverflow.com/a/31572888">this stackoverflow answer</a> could help you. </p>

CC BY-SA 3.0
2017-04-28T21:43:39.060Z
Please include a relevant quote from that linked answer ...
Pierre.Vriens
CC BY-SA 3.0
2017-04-28T22:22:29.323Z
Welcome to DevOps! Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference.
Richard Slater
CC BY-SA 3.0
2017-04-29T00:06:31.753Z
@RichardSlater I'm not sure about the policy on DevOps, but other sites make an exception for in-network links.
chicks
CC BY-SA 3.0
2017-04-29T00:10:41.293Z
@chicks even StackOverflow links are subject to link rot and by summarising the question it gives a clear indication to other reasons why the answerer believes the question is answered by the link.
Richard Slater
CC BY-SA 3.0
2017-04-28T21:17:31.990Z
2017-04-28T21:17:31.990Z
2017-05-23T12:39:34.013Z
Fanch
<p>Yes, definitely. I do this all the time. You can specify configuration options for your pipeline and one of them is <code>skipDefaultCheckout</code>, which causes pipeline to skip the default "Declarative: Checkout SCM" stage.</p>

<p>The <code>skipDefaultCheckout</code> option is documented in <a href="https://jenkins.io/doc/book/pipeline/syntax/" rel="noreferrer">Pipeline Syntax</a> and here's an example Jenkinsfile showing how to use it:</p>

<pre><code>pipeline {
  agent { label 'docker' }
  options {
    skipDefaultCheckout true
  }
  stages {
    stage('commit_stage') {
      steps {
        echo 'sweet stuff here'
      }
    }
  }
}
</code></pre>

CC BY-SA 3.0
2017-09-10T05:11:54.897Z
How would you the. Manually clone the repository in a stage?
oz123
CC BY-SA 3.0
2017-09-11T02:29:16.193Z
you can run `checkout scm` to manually clone where you need to. see https://devops.stackexchange.com/a/1916/2450.
burnettk
CC BY-SA 3.0
2017-04-29T03:07:59.373Z
2017-04-29T19:15:23.757Z
2017-04-29T19:15:23.757Z
burnettk
<p>I have integrated Jenkins with Bitbucket using the <a href="https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin" rel="noreferrer">Bitbucket Plugin</a>. As per the plugin's Wiki, a given job will be triggered if the repository is set in the SCM of the job. As you know, if one set SCM in a Jenkins job, this is cloned in pre-build stage.</p>

<p>So far so good. However, the main purpose of the job I'm setting has nothing to do with the repository's content; instead, I just want the job to process the payload sent by Bitbucket. One could say it's not a big deal in terms of storage to clone a repository despite you really don't need it. I don't think so, adding unnecessary steps, consuming time and resources is not a good practice.</p>

<p>So, the question is: <strong>Does anyone know how to set an SCM in a Jenkins job but prevent it to clone the repository?</strong></p>

CC BY-SA 3.0
2017-03-29T16:33:22.863Z
It sounds like you're trying to use Jenkins as a micro service which is kind of out of the scope of Jenkins :).  Do post back if you get this working though because it is interesting.
Travis Thompson
CC BY-SA 3.0
2017-03-29T16:39:37.077Z
I'm not using Jenkins as a micro service. Why do you say that? In reality, all of this is a work around: I'm using a Pipeline Job which is common to many repositories. Jenkinsfile is in a different repository. Thus, I can't trigger the pipeline directly with the Bitbucket Plugin because it just don't trigger it, so I decided to create a "proxy job" per repo, and send the information to the pipeline as a downstream job. In such "proxy job" I don't need to clone the repo, but it needs to be in SCM.
Héctor Valverde
CC BY-SA 3.0
2017-04-24T19:45:31.257Z
It is very hard to understand and you write more about what is impossible than about what you actually want to achieve, Maybe you can add more details about what you are actually want to achieve and how your proxy jobs fit in there?
Michaël Le Barbier
CC BY-SA 3.0
2017-04-24T23:08:12.340Z
I guess you're talking about my comment above. It's just an answer to the first comment. Please refer to the main question, there is nothing else to add. What I want you achieve is very clear: "Prevent Jenkins to clone a repository during the build".
Héctor Valverde
CC BY-SA 3.0
2017-04-29T18:40:46.753Z
@HéctorValverdePareja Sure, but your wording seems to hesitate between A/giving enough details so that everybody can check if you're in a XY-problem situation and B/just to focus on the precise thing you want to achieve. I think (opinion) you could remove this hesitation by describing carefully enough your original problem and the solution you are trying to implement. But now that someone wrote an answer, this might be not so important anymore.
Michaël Le Barbier
CC BY-SA 4.0
2022-08-28T00:00:58.610Z
Hi @MichaëlLeBarbier - late recovery of this threat, sorry. I see my wording in the comment above was not clear (you were right on that), and I could give more context to the problem (to the expenses of simplicity). But despite I implicitly told you to ignore the anwer to Travis comment, your second comment still circled around it. I think you were wrong to criticise the narrative of my comment responding to the "side topic" of microservices, and you failed to recognise that the original post was clear enough.
Héctor Valverde
CC BY-SA 4.0
2022-08-28T08:02:38.000Z
If people who try to help you do not understand the problem you are describing and the problem you are trying to solve, it might be a good idea to rephrase, add more details etc. No biggie :-)
Michaël Le Barbier
<jenkins>
Set a Jenkins job to not to clone the repo in SCM
Héctor Valverde
# Set a Jenkins job to not to clone the repo in SCM

(Asked by: username_0 on 2017-03-25)

I have integrated Jenkins with Bitbucket using the [Bitbucket Plugin](https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin). As per the plugin's Wiki, a given job will be triggered if the repository is set in the SCM of the job. As you know, if one set SCM in a Jenkins job, this is cloned in pre-build stage.

So far so good. However, the main purpose of the job I'm setting has nothing to do with the repository's content; instead, I just want the job to process the payload sent by Bitbucket. One could say it's not a big deal in terms of storage to clone a repository despite you really don't need it. I don't think so, adding unnecessary steps, consuming time and resources is not a good practice.

So, the question is: **Does anyone know how to set an SCM in a Jenkins job but prevent it to clone the repository?**

**Tags:** jenkins

> **Comments:**
> **username_1**: It sounds like you're trying to use Jenkins as a micro service which is kind of out of the scope of Jenkins :).  Do post back if you get this working though because it is interesting.  
> **username_0**: I'm not using Jenkins as a micro service. Why do you say that? In reality, all of this is a work around: I'm using a Pipeline Job which is common to many repositories. Jenkinsfile is in a different repository. Thus, I can't trigger the pipeline directly with the Bitbucket Plugin because it just don't trigger it, so I decided to create a "proxy job" per repo, and send the information to the pipeline as a downstream job. In such "proxy job" I don't need to clone the repo, but it needs to be in SCM.  
> **username_2**: It is very hard to understand and you write more about what is impossible than about what you actually want to achieve, Maybe you can add more details about what you are actually want to achieve and how your proxy jobs fit in there?  
> **username_0**: I guess you're talking about my comment above. It's just an answer to the first comment. Please refer to the main question, there is nothing else to add. What I want you achieve is very clear: "Prevent Jenkins to clone a repository during the build".  
> **username_2**: @HéctorValverdePareja Sure, but your wording seems to hesitate between A/giving enough details so that everybody can check if you're in a XY-problem situation and B/just to focus on the precise thing you want to achieve. I think (opinion) you could remove this hesitation by describing carefully enough your original problem and the solution you are trying to implement. But now that someone wrote an answer, this might be not so important anymore.  
> **username_0**: Hi @MichaëlLeBarbier - late recovery of this threat, sorry. I see my wording in the comment above was not clear (you were right on that), and I could give more context to the problem (to the expenses of simplicity). But despite I implicitly told you to ignore the anwer to Travis comment, your second comment still circled around it. I think you were wrong to criticise the narrative of my comment responding to the "side topic" of microservices, and you failed to recognise that the original post was clear enough.  
> **username_2**: If people who try to help you do not understand the problem you are describing and the problem you are trying to solve, it might be a good idea to rephrase, add more details etc. No biggie :-)  

---

## 3 answers

### Answer by username_11 on 2017-04-29. Score: 27 | Accepted answer

Yes, definitely. I do this all the time. You can specify configuration options for your pipeline and one of them is skipDefaultCheckout, which causes pipeline to skip the default "Declarative: Checkout SCM" stage.
The skipDefaultCheckout option is documented in Pipeline Syntax and here's an example Jenkinsfile showing how to use it:
pipeline {
  agent { label 'docker' }
  options {
    skipDefaultCheckout true
  }
  stages {
    stage('commit_stage') {
      steps {
        echo 'sweet stuff here'
      }
    }
  }
}

> **Comments:**
> **username_12**: How would you the. Manually clone the repository in a stage?  
> **username_11**: you can run `checkout scm` to manually clone where you need to. see https://devops.stackexchange.com/a/1916/2450.  

---

### Answer by username_3 on 2017-10-06. Score: 8

In case you're not using the Declarative Pipeline, you can avoid checking out from SCM by:
node {
        skipDefaultCheckout()
        //...
}

> **Comments:**
> **username_4**: Could you add a link to the documentation and explain more about skipDefaultCheckout()?  
> **username_5**: I don't see any added value compared to existing answer, that's just a 'try this' with no explanation and not a good answer.  
> **username_6**: This answer is fine as a supplement to the accepted answer - not everyone will be using the declarative Pipeline plugin, so this works for those using the procedural one.  

---

### Answer by username_7 on 2017-04-28. Score: 2

I think what you want to achieve is processing a webhook payload in a Jenkins job. Using bitbucket plugin won't be necessary and it is probably strongly designed to clone the repo.

I belive [this stackoverflow answer](https://stackoverflow.com/a/31572888) could help you.

> **Comments:**
> **username_8**: Please include a relevant quote from that linked answer ...  
> **username_9**: Welcome to DevOps! Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference.  
> **username_10**: @RichardSlater I'm not sure about the policy on DevOps, but other sites make an exception for in-network links.  
> **username_9**: @username_10 even StackOverflow links are subject to link rot and by summarising the question it gives a clear indication to other reasons why the answerer believes the question is answered by the link.  

---

