jenkinsci / jenkinsci/gitlab-plugin

Send Gitlab MR Comments through generated job

Open
#1,071 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.4k
Forks
615
Avg merge
4h 32m
Merged PRs (30d)
10

Description

## Issue

### Context
- **Gitlab plugin version**: 1.5.13
- **Gitlab version**: 11.11.8
- **Jenkins version**: 2.150.3
- **Job type**: Pipeline Declarative

### Logs & Traces

Not needed in this context

### Problem description

_Describe your problem in a meaningful way_:
- what were you doing (simple push, merge request, MR with fork, ...)
- In Jenkins:
- create a job dsl generator using the following dsl code:
````
import jenkins.model.Jenkins

// Make sure folder exists
TARGET_FOLDER_PATHS = TARGET_JOB_NAME.split('/')
TARGET_FOLDER_PATHS = TARGET_FOLDER_PATHS[0..-2]
println("Detected folder paths: ${TARGET_FOLDER_PATHS}")
parent_folder_path = '/'
parent_item = Jenkins.instance
TARGET_FOLDER_PATHS.each {
current_path = "${parent_folder_path}/${it}"
current_item = parent_item.getItem(it)
if ( current_item ) {
println("${current_path} exists")
} else {
folder(current_path) {
description("Created by ${JOB_NAME}")
}
current_item = parent_item.getItem(it)
}
parent_item = current_item
parent_folder_path = current_path
}

envToPropagate = [:]

for (entry in binding.variables) {
switch( entry.key ) {
case ~/gitlab.*/:
envToPropagate[entry.key] = entry.value
break
}
}

println("Env to propagate: ${envToPropagate}")

pipelineJob("${TARGET_JOB_NAME}") {
disabled(false)
properties {
gitLabConnection {
gitLabConnection('gitlab')
}
}
environmentVariables {
envs(envToPropagate)
keepBuildVariables(true)
overrideBuildParameters(false)
}

triggers {
gitlabPush {
buildOnMergeRequestEvents()
buildOnPushEvents()
commentTrigger('Jenkins please retry a build')
enableCiSkip()
rebuildOpenMergeRequest('both')
skipWorkInProgressMergeRequest()
}
}

definition {
cpsScm {
scm {
git {
branch('test/job-creator')
remote {
url("urltocentralisedpipelineproject.git")
credentials('gitlab_user')
}
}
scriptPath("Jenkinsfile")
}
}
}
}

````
- In Gitlab: configure each project webhooks to point to generator job /project url
- Create MR
- what was expected
- new jenkins job is generated and adds comments to MR
- what occurred finally
- new job is generated, build status is propaged to gitlab source project but no MR comments

Is it possible to allow MRComments in this case. Without generated job pipeline is working and send MR comments

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.