diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..012c17d2a58739702c0b1cf9ed611c79e98573ea --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,69 @@ +stages: + - build + - analyse + - publish + - image + - release + +build: + stage: build + image: registry.esss.lu.se/ics-docker/maven:openjdk-11 + tags: + - docker + script: + - mvn --batch-mode install + artifacts: + paths: + - target/ + expire_in: 1 day + +# sonar: +# stage: analyse +# image: registry.esss.lu.se/ics-docker/maven:openjdk-11 +# tags: +# - docker +# script: +# - mvn --batch-mode sonar:sonar -Dsonar.login=$SONARQUBE_TOKEN -Dsonar.branch.name=$CI_COMMIT_REF_SLUG +# only: +# - branches@ics-software/channelfinderservice + +publish: + stage: publish + image: registry.esss.lu.se/ics-docker/maven:openjdk-11 + tags: + - docker + script: + - mvn --batch-mode deploy -Dartifactory.username=${ARTIFACTORY_USERNAME} -Dartifactory.password=${ARTIFACTORY_PASSWORD} + only: + - master@ics-software/channelfinderservice + +docker-build: + stage: image + image: docker:latest + tags: + - docker + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG . + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + only: + - branches + +docker-release: + stage: release + image: docker:latest + tags: + - docker + before_script: + - apk add xmlstarlet + - POM_VERSION=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -v "/pom:project/pom:version" pom.xml) + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG $CI_REGISTRY_IMAGE:$POM_VERSION + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG $CI_REGISTRY_IMAGE:latest + - docker push $CI_REGISTRY_IMAGE:$POM_VERSION + - docker push $CI_REGISTRY_IMAGE:latest + only: + - master diff --git a/pom.xml b/pom.xml index 3815e593315bcf6c7f91b8c515f270ea2ed7668f..7afed621b069e755b79f83a91a1df886c5abb151 100644 --- a/pom.xml +++ b/pom.xml @@ -157,6 +157,35 @@ </archive> </configuration> </plugin> + <plugin> + <groupId>org.jfrog.buildinfo</groupId> + <artifactId>artifactory-maven-plugin</artifactId> + <version>3.2.1</version> + <inherited>false</inherited> + <executions> + <execution> + <id>build-info</id> + <goals> + <goal>publish</goal> + </goals> + <configuration> + <publisher> + <contextUrl>${artifactory.url}</contextUrl> + <username>${artifactory.username}</username> + <password>${artifactory.password}</password> + <repoKey>libs-release-local</repoKey> + <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey> + </publisher> + <buildInfo> + <agentName>{{JENKINS_URL}}</agentName> + <agentVersion>{{JENKINS_VERSION}}</agentVersion> + <buildNumber>{{BUILD_NUMBER}}</buildNumber> + <buildUrl>{{BUILD_URL}}</buildUrl> + </buildInfo> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> <profiles>