Jenkins - How to use the same workspace as Multi-branch for Jenkins PR jobs

664 views Asked by At

Backgroud:

I have setup a Multi-branch job that checks the repository and triggers through the Github webhook a build for every push on a branch.

Jenkinsfile is present on branches.

There are several stages present but the checkout scm is made using the same workspace location for all branches (repo > 1GB):

node("Node_Name") {
    ws(workspacePath) {
        echo "Checking out code on ${env.NODE_NAME}"
        checkout scm

        buildSolution()
    }
}

Problem

When I set up to also trigger a job at a pull request, that particular job is triggered but it's ignoring the custom workspace set up in Jenkinsfile (present in both branches).

Any hints on how I could solve this? Checking out the entire repository (> 1GB) for every pull request takes up a lot of time, so I'd prefer avoiding this.

0

There are 0 answers