jenkinsci / jenkinsci/gitlab-plugin
Cannot configure gitlab connection nor gitlab triggering options via CASC
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 615
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 10
Description
### Jenkins and plugins versions report
Environment
```
Jenkins: 2.332
OS: Linux - 5.10.0-0.bpo.8-amd64
---
ace-editor:1.1
antisamy-markup-formatter:2.7
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.4
authorize-project:1.4.0
basic-branch-build-strategies:1.3.2
bootstrap4-api:4.6.0-3
bootstrap5-api:5.1.3-4
bouncycastle-api:2.25
branch-api:2.7.0
caffeine-api:2.9.2-29.v717aac953ff3
checks-api:1.7.2
cloudbees-folder:6.17
command-launcher:1.2
configuration-as-code:1.55.1
credentials:1074.v60e6c29b_b_44b_
credentials-binding:1.27.1
display-url-api:2.3.5
docker-commons:1.18
docker-workflow:1.27
durable-task:493.v195aefbb0ff2
echarts-api:5.2.2-2
envinject:2.4.0
envinject-api:1.8
extended-read-permission:3.2
font-awesome-api:5.15.4-5
git:4.10.3
git-client:3.11.0
git-server:1.10
gitlab-plugin:1.5.27
handlebars:3.0.8
jackson2-api:2.13.1-246.va8a9f3eaf46a
javax-activation-api:1.2.0-2
javax-mail-api:1.6.2-5
jaxb:2.3.0
jdk-tool:1.0
jersey2-api:2.35-3
job-dsl:1.78.3
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.53
kubernetes:1.31.3
kubernetes-client-api:5.11.2-182.v0f1cf4c5904e
kubernetes-credentials:0.9.0
ldap:2.7
lockable-resources:2.13
mailer:408.vd726a_1130320
matrix-auth:3.0.1
matrix-project:1.20
mattermost:3.1.1
metrics:4.0.2.8.1
momentjs:1.1.1
multibranch-action-triggers:1.8.6
pipeline-build-step:2.15
pipeline-graph-analysis:188.v3a01e7973f2c
pipeline-input-step:446.vf27b_0b_83500e
pipeline-milestone-step:1.3.2
pipeline-model-api:1.9.3
pipeline-model-definition:1.9.3
pipeline-model-extensions:1.9.3
pipeline-rest-api:2.21
pipeline-stage-step:291.vf0a8a7aeeb50
pipeline-stage-tags-metadata:1.9.3
pipeline-stage-view:2.21
plain-credentials:1.8
plugin-util-api:2.13.0
popper-api:1.16.1-2
popper2-api:2.11.2-1
prometheus:2.0.10
promoted-builds:3.11
scm-api:595.vd5a_df5eb_0e39
script-security:1131.v8b_b_5eda_c328e
snakeyaml-api:1.29.1
sonar:2.14
sonar-quality-gates:1.3.1
ssh:2.6.1
ssh-agent:1.24.1
ssh-credentials:1.19
ssh-slaves:1.33.0
sshd:3.1.0
structs:308.v852b473a2b8c
token-macro:267.vcdaea6462991
trilead-api:1.0.13
uno-choice:2.5.7
variant:1.4
workflow-aggregator:2.6
workflow-api:1136.v7f5f1759dc16
workflow-basic-steps:2.24
workflow-cps:2648.va9433432b33c
workflow-cps-global-lib:552.vd9cc05b8a2e1
workflow-durable-task-step:1121.va_65b_d2701486
workflow-job:1167.v8fe861b_09ef9
workflow-multibranch:706.vd43c65dec013
workflow-scm-step:2.13
workflow-step-api:622.vb_8e7c15b_c95a_
workflow-support:813.vb_d7c3d2984a_0
```
### What Operating System are you using (both controller, and any agents involved in the problem)?
master running in Kubernetes using docker image jenkins/jenkins:2.332-jdk11
slaves running in Kubernetes using docker image 3.8.4-openjdk-11
### Reproduction steps
1. Create a pipelineJob using CASC
```
pipelineJob('MyName') {
parameters {
stringParam('gitlabSourceBranch', '', 'Gitlab branch to build')
}
definition {
cpsScm {
scm {
git {
remote {
name("origin")
url('git@git.url.net:namespace/project.git')
credentials('gitlab-deploy-key')
branch('$gitlabSourceBranch')
}
}
scriptPath('Jenkinsfile')
}
}
}
logRotator {
numToKeep(20)
artifactNumToKeep(5)
}
}
```
2. Configure gitlab connection and triggering options using scripted Jenkinsfile
```
properties([
gitLabConnection(gitLabConnection: 'git.url.com',
jobCredentialId: "gitlab-token-api",
useAlternativeCredential: true),
pipelineTriggers([
[
$class: 'GitLabPushTrigger',
branchFilterType: 'All',
triggerOnPush: true,
triggerOnMergeRequest: false,
triggerOpenMergeRequestOnPush: "never",
triggerOnNoteRequest: true,
noteRegex: "Jenkins please retry a build",
skipWorkInProgressMergeRequest: true,
secretToken: project_token,
ciSkip: false,
setBuildDescription: true,
addNoteOnMergeRequest: true,
addCiMessage: true,
addVoteOnMergeRequest: true
]
])
])
```
### Expected Results
- "Use alternative credential" should be checked and credential selected.
- "Build when a change is pushed to GitLab." should be checked and requested options selected.
### Actual Results
Checkboxes are not selected when reloading configuration in **Manage Jenkins > Configuration as code > Reload existing configuration.**
### Anything else?
- There is no log error related to this in jenkins logs (from Manage Jenkins nor from the container logs)
- I have 2 jobs using the exact same configuration with the exact same symptoms
- If I go afterward to the job, I can just select my gitlab credential in the list (the same one that is in the code), and manually select the triggering options, save, and they will remain selected until I reload the configuration.
- project_token is define above in my Jenkinsfile
Contributor guide
Assessment
This issue has not been assessed yet.