How to setup Gradle publish task user credentials with GitLab CI secret variables? I am using gradle maven publish plugin, and here is snippet from build.gradle
Here is how I resolved it (unfortunately the official GitLab doco is very focused on Maven... :(
apply plugin: 'java'
apply plugin: 'maven-publish'
compileJava.options.encoding = 'UTF-8'
group = 'com.example'
version = '1.0.9'
task zipSource(type: Zip) {
from file('files/test.zip')
archiveClassifier = 'testZip'
}
publishing {
repositories {
maven {
name 'GitLab'
url 'https://gitlab.my-company.com/api/v4/projects/2302/packages/maven'
credentials(HttpHeaderCredentials) {
name = "Job-Token"
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
publications {
mavenJava(MavenPublication) {
artifactId = 'project1-sample'
//deploy jar vom Java
from components.java
//deploy arbitrary Zip file
artifact zipSource
}
}
}