Hi,
AFAIK there’s no way via sonar-project.properties.
To work efficiently with Sonarqube your Gitlab user needs global admin rights.
Then you can use either cURL or some groovy method with a token = type global / no expiration
and basic authentication for your rest calls.
This can also be part of a provisioning workflow (using the rest api).
Basic authentication uses <token>:
means just the token plus delimiter with a blank password.
An example for using Groovy, this is one of my Jenkins shared libraries
The CPS stuff is needed for Jenkins, don’t know if Gitlab needs something similar too.
// vars/sqRest.groovy
import groovy.json.*
@NonCPS
def call(url, method, apitoken) {
// must use def for jsonSlurper and conn otherwise cps errors
println "sqRest => " + url
def jsonSlurper = new JsonSlurperClassic()
bauth = 'Basic ' + (apitoken + ':').bytes.encodeBase64().toString()
def conn = url.toURL().openConnection()
conn.setRequestMethod(method)
conn.setRequestProperty("Authorization", bauth)
conn.connect()
httpstatus = conn.responseCode
println "sqRest ResponseCode = $httpstatus"
if(method == 'GET') {
object = jsonSlurper.parseText(conn.content.text)
}
}
There may also be some automatism via Gitlab integration, but i don’t know much about
Gitlab, see GitLab integration
Gilbert