From aad1a52cac6557bb99012bf7fadf2e1f7700a4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sun, 21 Feb 2021 14:08:22 +0100 Subject: [PATCH 1/7] Add gitlab-ci template --- .gitignore | 1 - .gitlab-ci.yml | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitignore b/.gitignore index ac00849..7698d43 100644 --- a/.gitignore +++ b/.gitignore @@ -65,4 +65,3 @@ hs_err_pid* # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* - diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5c2e31e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,18 @@ +# Based on https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Gradle.gitlab-ci.yml +image: gradle:alpine + +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + +before_script: + - export GRADLE_USER_HOME=`pwd`/.gradle + +build: + stage: build + script: gradle --build-cache assemble + cache: + key: "$CI_COMMIT_REF_NAME" + policy: push + paths: + - build + - .gradle From 4bb1144eac12f2d058a582026616be5d9fa15e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sun, 21 Feb 2021 14:38:16 +0100 Subject: [PATCH 2/7] Try adding some publish task. --- .gitlab-ci.yml | 10 ++++++++++ build.gradle.kts | 10 ++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c2e31e..9d22d42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,3 +16,13 @@ build: paths: - build - .gradle + +artifact: + stage: deploy + script: gradle publish + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull-push + paths: + - build + - .gradle diff --git a/build.gradle.kts b/build.gradle.kts index 407fbf8..a92989d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -53,6 +53,16 @@ publishing { from(components["javaPlatform"]) } } + repositories { + maven { + url = uri("https://git.f3l.de/api/v4/groups/160/packages/maven") + name = "GitLab" + credentials(HttpHeaderCredentials::class.java) { + name = "Job-Token" + value = System.getenv("CI_JOB_TOKEN") + } + } + } } inline fun getFromProperties(name: String): T = project.properties[name] as T diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 12d38de..2a56324 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From ee60d309f8cf9004ec4022c17d0679d2fa7061bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sun, 21 Feb 2021 14:43:02 +0100 Subject: [PATCH 3/7] Add additional auth. --- build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index a92989d..3bc834c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,6 +61,9 @@ publishing { name = "Job-Token" value = System.getenv("CI_JOB_TOKEN") } + authentication { + create("header") + } } } } From c08d5930f8d7de70ef29b4cb31bd327f1f4e76f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sun, 21 Feb 2021 14:47:29 +0100 Subject: [PATCH 4/7] Try more recent version of gradle docker container --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d22d42..56d3bf6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ # Based on https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Gradle.gitlab-ci.yml -image: gradle:alpine +image: gradle:jdk11 variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" From 417005db420732bd834d1b1ac8c5aa76787b3cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sun, 21 Feb 2021 14:49:38 +0100 Subject: [PATCH 5/7] Specify auth type. --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3bc834c..2beaee1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,7 +62,7 @@ publishing { value = System.getenv("CI_JOB_TOKEN") } authentication { - create("header") + create("header") } } } From d375455dfa271bb8cc1f7fd775249849be530422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Fri, 5 Mar 2021 21:22:44 +0100 Subject: [PATCH 6/7] Use `project` instead of `group` --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2beaee1..cc8c9af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -55,7 +55,7 @@ publishing { } repositories { maven { - url = uri("https://git.f3l.de/api/v4/groups/160/packages/maven") + url = uri("https://git.f3l.de/api/v4/projects/160/packages/maven") name = "GitLab" credentials(HttpHeaderCredentials::class.java) { name = "Job-Token" From f470c1ccd8ce123f7816329ac355c266a347167d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sat, 6 Mar 2021 19:24:10 +0100 Subject: [PATCH 7/7] Try adding master restriction for publish --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 56d3bf6..c0eb90c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,8 @@ build: artifact: stage: deploy script: gradle publish + rules: + - if: '$CI_COMMIT_BRANCH == "master"' cache: key: "$CI_COMMIT_REF_NAME" policy: pull-push