jenkinsci / jenkinsci/gitlab-branch-source-plugin

MR clone with Group Pipeline not working

Open
#150 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
134
Forks
113
PR merge metrics
No merged PRs in 30d

Description

### Version report

GitLab EE 13.12.3-ee

```
Jenkins: 2.299
OS: Windows Server 2012 - 6.2
---
ace-editor:1.1
active-directory:2.24
analysis-core:1.96
ant:1.11
antisamy-markup-formatter:2.1
apache-httpcomponents-client-4-api:4.5.13-1.0
artifactdeployer:1.2
artifactory:3.11.4
authentication-tokens:1.4
blueocean-commons:1.24.7
blueocean-core-js:1.24.7
blueocean-dashboard:1.24.7
blueocean-jwt:1.24.7
blueocean-pipeline-api-impl:1.24.7
blueocean-pipeline-editor:1.24.7
blueocean-pipeline-scm-api:1.24.7
blueocean-rest-impl:1.24.7
blueocean-rest:1.24.7
blueocean-web:1.24.7
bootstrap4-api:4.6.0-3
bootstrap5-api:5.0.1-2
bouncycastle-api:2.20
branch-api:2.6.4
build-keeper-plugin:1.3
build-pipeline-plugin:1.5.8
caffeine-api:2.9.1-23.v51c4e2c879c8
checks-api:1.7.0
cloudbees-folder:6.15
cobertura:1.16
code-coverage-api:1.4.0
command-launcher:1.6
conditional-buildstep:1.4.1
config-file-provider:3.8.0
credentials-binding:1.26
credentials:2.5
cvs:2.19
data-tables-api:1.10.25-1
deploy:1.16
display-url-api:2.3.5
docker-commons:1.17
docker-compose-build-step:1.0
docker-java-api:3.1.5.2
docker-plugin:1.2.2
docker-workflow:1.26
dotnet-as-script:1.0.2
dtkit-api:3.0.0
durable-task:1.37
dynamicparameter:0.2.0
echarts-api:5.1.2-2
email-ext:2.83
envinject-api:1.7
envinject:2.4.0
external-monitor-job:1.7
favorite:2.3.3
files-found-trigger:1.5
font-awesome-api:5.15.3-3
forensics-api:1.1.0
fstrigger:0.41
generic-webhook-trigger:1.74
git-client:3.7.2
git-server:1.9
git:4.7.2
github-api:1.123
github-branch-source:2.11.1
github-organization-folder:1.6
github:1.33.1
gitlab-api:1.0.6
gitlab-branch-source:1.5.7
gradle:1.36
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-1.0
htmlpublisher:1.25
http-post:1.2
icon-shim:3.0.0
ivy:2.1
jackson2-api:2.12.3
javadoc:1.6
jdk-tool:1.5
jenkins-design-language:1.24.7
jira:3.5
jjwt-api:0.11.2-9.c8b45b8bb173
job-dsl:1.77
jquery-detached:1.2.1
jquery:1.12.4-1
jquery3-api:3.6.0-1
jsch:0.1.55.2
junit:1.50
ldap:2.7
ldapemail:0.8
lockable-resources:2.11
m2release:0.16.2
mailer:1.34
mapdb-api:1.0.9.0
matrix-auth:2.6.7
matrix-project:1.19
maven-plugin:3.12
momentjs:1.1.1
msbuild:1.30
mstest:1.0.0
mstestrunner:1.3.0
nant:1.4.3
nodejs:1.4.0
nuget:1.1
nunit:0.27
Office-365-Connector:4.15.0
okhttp-api:3.14.9
opencover:1.0.3
pam-auth:1.6
parameterized-trigger:2.41
pipeline-build-step:2.13
pipeline-github-lib:1.0
pipeline-graph-analysis:1.11
pipeline-input-step:2.12
pipeline-milestone-step:1.3.2
pipeline-model-api:1.8.5
pipeline-model-declarative-agent:1.1.1
pipeline-model-definition:1.8.5
pipeline-model-extensions:1.8.5
pipeline-npm:0.9.2
pipeline-rest-api:2.19
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.8.5
pipeline-stage-view:2.19
pipeline-utility-steps:2.8.0
plain-credentials:1.7
plugin-util-api:2.3.0
pollscm:1.3.1
popper-api:1.16.1-2
popper2-api:2.5.4-2
postbuild-task:1.9
powershell:1.5
preSCMbuildstep:0.3
pubsub-light:1.16
resource-disposer:0.16
run-condition:1.5
saferestart:0.3
scm-api:2.6.4
script-security:1.77
scriptler:3.3
slack:2.48
snakeyaml-api:1.29.1
sonar:2.13.1
ssh-agent:1.23
ssh-credentials:1.19
ssh-slaves:1.32.0
sshd:3.0.3
status-view:1.0
structs:1.23
subversion:2.14.4
token-macro:2.15
translation:1.16
trilead-api:1.0.13
urltrigger:0.49
variant:1.4
veracode-scan:21.6.13.0
viewVC:1.7
windows-slaves:1.8
workflow-aggregator:2.6
workflow-api:2.46
workflow-basic-steps:2.23
workflow-cps-global-lib:2.21
workflow-cps:2.92
workflow-durable-task-step:2.39
workflow-job:2.41
workflow-multibranch:2.26
workflow-scm-step:2.13
workflow-step-api:2.23
workflow-support:3.8
ws-cleanup:0.39
xunit:3.0.2
```

- What Operating System are you using (both controller, and any agents involved in the problem)?

```
Windows 2019 Server
```

### Reproduction steps

I have a number of projects hosted in GitLab EE (under a group). The main branch is protected, merge requests are raised to push changes back to main.

I have created a Jenkins "GitLab Group" pointing to the group, and all the project underneath are recognized and builds are triggering as expected for the main and other branches, however, merge requests are being detected but when the job execute the clone / pull step fails in the JenkinsFile.

I suspect the issue is the checkout, but cannot work out what to change here to make it work ...

```groovy
def scmVars = checkout ([
$class: 'GitSCM',
branches: scm.branches,
extensions: [
[$class: 'CleanBeforeCheckout'],
[$class: 'PruneStaleBranch']],
userRemoteConfigs: [[
credentialsId: 'blahblah-jenkins-ci',
url: 'ssh://git@blahblah.blah.blah.com:7888/group1/group2/project.git'
]]
])
```

I wonder if it might be something to o with the `refspec` not being set, above to `+refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*` .

```sh
refspec: '+refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*',
```

### Results

Expected result:

Successful checkout / clone of MR.

Actual result:

```
The recommended git tool is: NONE
using credential sunsystems-jenkins-ci
Cloning the remote Git repository
Cloning repository ssh://git@blahblah.blah.blah.com:7888/group1/group2/project.git
> git.exe init C:\Jenkins\workspace\Microsoft_Api_MR-1 # timeout=10
Fetching upstream changes from ssh://git@blahblah.blah.blah.com:7888/group1/group2/project.git
> git.exe --version # timeout=10
> git --version # 'git version 2.32.0.windows.1'
using GIT_SSH to set credentials SunSystems Jenkins CI
> git.exe fetch --tags --force --progress -- ssh://git@blahblah.blah.blah.com:7888/group1/group2/project.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
[Pipeline] }
[Pipeline] // script
[Pipeline] }
> git.exe config remote.origin.url ssh://git@blahblah.blah.blah.com:7888/group1/group2/project.git # timeout=10
> git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe rev-parse "origin/MR-1^{commit}" # timeout=10
> git.exe rev-parse "MR-1^{commit}" # timeout=10
[Pipeline] // stage
[Pipeline] stage
[Pipeline] End of Pipeline
...
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
[GitLab Pipeline Status] Notifying merge request build status: FAILED group2/project/MR-1: There was a failure building this commit
[GitLab Pipeline Status] Notified
Finished: FAILURE
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.