Skip to content

Commit

Permalink
Merge branch 'release/0.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Dec 21, 2021
2 parents f550004 + 807ac41 commit 599f51d
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 34 deletions.
31 changes: 11 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
pipeline {
agent any
agent {
docker {
image 'maven:3.8.3-openjdk-17'
args '-v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -v /var/run/docker.sock:/var/run/docker.sock:ro -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven'
}
}
options {
disableConcurrentBuilds()
}
parameters {
string(name: 'VERSION', defaultValue: 'latest', description: 'The docker image version to deploy')
}
environment {
DOCKER_REGISTRY = credentials('github_docker_registry')
COVERALLS_REPO_TOKEN = credentials('coveralls_repo_token_gh_prom_exporter')
}
stages {
stage('Build Image') {
agent {
docker {
image 'maven:3.8.3-openjdk-17'
args '-u root -v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -v /var/run/docker.sock:/var/run/docker.sock:ro -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven'
}
}
stage('Build') {
steps {
sh 'mvn -B "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image'
sh 'mvn -B clean verify'
}
}
stage('Deploy') {
agent any
when {
branch 'master'
}
stage('Coverage') {
steps {
sh 'docker login -u ${DOCKER_REGISTRY_USR} -p ${DOCKER_REGISTRY_PSW} ghcr.io'
sh 'docker stack deploy --compose-file swarm-stack/production.yml --prune --with-registry-auth gh-prom-exporter'
sh 'mvn -B jacoco:report jacoco:report-integration coveralls:report -DrepoToken=$COVERALLS_REPO_TOKEN'
}
}
}
Expand Down
75 changes: 75 additions & 0 deletions JenkinsfileRelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
pipeline {
agent {
docker {
image 'maven:3.8.3-openjdk-17'
args '-u 1000:999 -v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -v /var/run/docker.sock:/var/run/docker.sock:ro -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven'
}
}
environment {
GITHUB = credentials('Github-Username-Pw')
DOCKER_REGISTRY = credentials('github_docker_registry')
GITHUB_RELEASE_TOKEN = credentials('github_registry_release')
GIT_ASKPASS='./.git-askpass'
VERSION = 'latest'
}
stages {
stage ('Ensure dev branch') {
when {
expression {
return env.BRANCH_NAME != 'dev';
}
}
steps {
error("Releasing is only possible from dev branch")
}
}
stage ('Set Git Information') {
steps {
sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass'
sh 'chmod +x ./.git-askpass'
sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"'
sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"'
sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"'
sh 'git config user.email "build@taddiken.online"'
sh 'git config user.name "Jenkins"'
}
}
stage('Create release branch') {
steps {
sh 'mvn -B -Prelease gitflow:release-start'
}
}
stage('Verify Release') {
steps {
sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image'
}
}
stage('Update readme') {
steps {
sh 'git add README.md RELEASE_NOTES.md'
sh 'git commit -m "Update README and RELEASE_NOTES"'
}
}
stage('Perform release') {
steps {
sh "mvn -B gitflow:release-finish"
}
}
stage('Create GitHub release') {
steps {
sh 'git checkout master'
sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}"
}
}
stage('Deploy to production') {
agent any
when {
branch 'master'
}
steps {
sh 'docker login -u ${DOCKER_REGISTRY_USR} -p ${DOCKER_REGISTRY_PSW} ghcr.io'
sh 'docker stack deploy --compose-file swarm-stack/production.yml --prune --with-registry-auth gh-prom-exporter'
}
}
}
}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<!-- This file is auto generated during release from readme/README.md -->

[![Coverage Status](https://coveralls.io/repos/github/skuzzle/gh-prom-exporter/badge.svg?branch=master)](https://coveralls.io/github/skuzzle/gh-prom-exporter?branch=master)
[![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS)


# gh-prom-exporter

Export your favorite GitHub repositories to Prometheus

Stay tuned, detailed documentation follows...
Use it _as a service_: https://gh.skuzzle.de

Stay tuned, detailed documentation for on-premise use follows...
10 changes: 10 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- This file is auto generated during release from readme/RELEASE_NOTES.md -->

[![Coverage Status](https://coveralls.io/repos/github/skuzzle/gh-prom-exporter/badge.svg?branch=master)](https://coveralls.io/github/skuzzle/gh-prom-exporter?branch=master)
[![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS)

* Test Release

```
docker pull ghcr.io/skuzzle/gh-prom-exporter/gh-prom-exporter:0.0.1
```
89 changes: 76 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,42 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.0</version>
<groupId>de.skuzzle</groupId>
<artifactId>skuzzle-parent</artifactId>
<version>3.0.2-SNAPSHOT</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<groupId>de.skuzzle.ghpromexporter</groupId>
<artifactId>gh-prom-exporter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>

<name>gh-prom-exporter</name>
<description>Demo project for Spring Boot</description>
<description>Export GitHub repository metrics in prometheus format</description>

<properties>
<spring-cloud.version>2021.0.0-RC1</spring-cloud.version>
<java.version>17</java.version>
<!-- Enable Code coverage -->
<coveralls.skip>false</coveralls.skip>
<!-- Skip dependency analysis (not compatible with Java 17 by now) -->
<mdep.analyze.skip>true</mdep.analyze.skip>
<!-- Skip javadoc (not needed and also not compatible with Java 17 by now) -->
<maven.javadoc.skip>true</maven.javadoc.skip>
<!-- Do not deploy to Maven Central -->
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
<!-- Do not sign jars -->
<gpg.skip>true</gpg.skip>

<github.name>gh-prom-exporter</github.name>

<docker.registry.name>ghcr.io</docker.registry.name>
<spring-boot.build-image.imageName>${docker.registry.name}/${github.user}/${github.name}/${project.artifactId}</spring-boot.build-image.imageName>

<spring-boot.version>2.6.1</spring-boot.version>
<spring-cloud.version>2021.0.0-RC1</spring-cloud.version>
<guava.version>31.0.1-jre</guava.version>
<github-api.version>1.135</github-api.version>
<snapshottest.version>0.0.4</snapshottest.version>
</properties>

<repositories>
Expand All @@ -40,6 +58,13 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
Expand All @@ -57,6 +82,12 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>de.skuzzle.test</groupId>
<artifactId>snapshot-tests</artifactId>
<version>${snapshottest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -129,24 +160,57 @@
<dependency>
<groupId>de.skuzzle.test</groupId>
<artifactId>snapshot-tests</artifactId>
<version>0.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>validate</phase>
<configuration>
<outputDirectory>${basedir}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>readme/</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.amashchenko.maven.plugin</groupId>
<artifactId>gitflow-maven-plugin</artifactId>
<configuration>
<postReleaseGoals>clean</postReleaseGoals>
</configuration>
</plugin>
<plugin>
<groupId>com.ragedunicorn.tools.maven</groupId>
<artifactId>github-release-maven-plugin</artifactId>
<configuration>
<releaseNotes>RELEASE_NOTES.md</releaseNotes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<image>
<name>ghcr.io/skuzzle/gh-prom-exporter/${project.artifactId}</name>
</image>
<network>host</network>
<docker>
<publishRegistry>
<url>https://ghcr.io</url>
<url>https://${docker.registry.name}</url>
<username>${docker.publish.usr}</username>
<password>${docker.publish.psw}</password>
<email>simon@taddiken.online</email>
Expand All @@ -156,5 +220,4 @@
</plugin>
</plugins>
</build>

</project>
13 changes: 13 additions & 0 deletions readme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- This file is auto generated during release from readme/README.md -->

[![Coverage Status](https://coveralls.io/repos/github/${github.user}/${github.name}/badge.svg?branch=${github.main-branch})](https://coveralls.io/github/${github.user}/${github.name}?branch=${github.main-branch})
[![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS)


# gh-prom-exporter

Export your favorite GitHub repositories to Prometheus

Use it _as a service_: https://gh.skuzzle.de

Stay tuned, detailed documentation for on-premise use follows...
10 changes: 10 additions & 0 deletions readme/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- This file is auto generated during release from readme/RELEASE_NOTES.md -->

[![Coverage Status](https://coveralls.io/repos/github/${github.user}/${github.name}/badge.svg?branch=${github.main-branch})](https://coveralls.io/github/${github.user}/${github.name}?branch=${github.main-branch})
[![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS)

* Test Release

```
docker pull ${spring-boot.build-image.imageName}:${project.version}
```

0 comments on commit 599f51d

Please sign in to comment.