Unverified Commit 48804220 authored by Gautier de Saint Martin Lacaze's avatar Gautier de Saint Martin Lacaze Committed by GitHub
Browse files

Merge branch 'master' into master

parents 28c40be0 ebaf80e6
root = true
[*]
insert_final_newline = true
[*.java]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
name: Build
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B test org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
# GitlLab4J&trade; API (gitlab4j-api)<br />Java Client Library for the GitLab REST API # GitLab4J&trade; API (gitlab4j-api)<br />Java Client Library for the GitLab REST API
[![Maven Central](https://img.shields.io/maven-central/v/org.gitlab4j/gitlab4j-api.svg)](http://mvnrepository.com/artifact/org.gitlab4j/gitlab4j-api) [![Maven Central](https://img.shields.io/maven-central/v/org.gitlab4j/gitlab4j-api.svg)](http://mvnrepository.com/artifact/org.gitlab4j/gitlab4j-api)
[![Build Status](https://travis-ci.org/gitlab4j/gitlab4j-api.svg?branch=master)](https://travis-ci.org/gitlab4j/gitlab4j-api) [![Build Status](https://travis-ci.org/gitlab4j/gitlab4j-api.svg?branch=master)](https://travis-ci.org/gitlab4j/gitlab4j-api)
...@@ -54,7 +54,7 @@ To utilize GitLab4J&trade; API in your Java project, simply add the following de ...@@ -54,7 +54,7 @@ To utilize GitLab4J&trade; API in your Java project, simply add the following de
```java ```java
dependencies { dependencies {
... ...
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.15.7' compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.16.0'
} }
``` ```
...@@ -65,7 +65,7 @@ dependencies { ...@@ -65,7 +65,7 @@ dependencies {
<dependency> <dependency>
<groupId>org.gitlab4j</groupId> <groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId> <artifactId>gitlab4j-api</artifactId>
<version>4.15.7</version> <version>4.16.0</version>
</dependency> </dependency>
``` ```
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gitlab4j</groupId> <groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId> <artifactId>gitlab4j-api</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>4.15.8-SNAPSHOT</version> <version>4.17.0-SNAPSHOT</version>
<name>GitLab4J-API - GitLab API Java Client</name> <name>GitLab4J-API - GitLab API Java Client</name>
<description>GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.</description> <description>GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.</description>
<url>https://github.com/gitlab4j/gitlab4j-api</url> <url>https://github.com/gitlab4j/gitlab4j-api</url>
<distributionManagement> <distributionManagement>
<snapshotRepository> <snapshotRepository>
<id>ossrh</id> <id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository> </snapshotRepository>
<repository> <repository>
<id>ossrh</id> <id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<licenses> <licenses>
<license> <license>
<name>The MIT License (MIT)</name> <name>The MIT License (MIT)</name>
<url>http://opensource.org/licenses/MIT</url> <url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution> <distribution>repo</distribution>
</license> </license>
</licenses> </licenses>
<developers> <developers>
<developer> <developer>
<id>gmessner</id> <id>gmessner</id>
<name>Greg Messner</name> <name>Greg Messner</name>
<email>greg@messners.com</email> <email>greg@messners.com</email>
</developer> </developer>
</developers> <developer>
<id>gdesaintmartinlacaze</id>
<properties> <name>Gautier de Saint Martin Lacaze</name>
<java.level>8</java.level> <email>gautier@jabby-techs.fr</email>
<java.source.version>1.8</java.source.version> </developer>
<java.target.version>1.8</java.target.version> </developers>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.level>8</java.level>
<java.source.version>1.8</java.source.version>
<jersey.version>2.30.1</jersey.version> <java.target.version>1.8</java.target.version>
<jackson.version>2.10.3</jackson.version>
<servlet.version>4.0.3</servlet.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<activation.version>1.2.2</activation.version> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<junit.version>5.6.0</junit.version> <jersey.version>2.30.1</jersey.version>
<mockito.version>3.3.0</mockito.version> <jackson.version>2.10.3</jackson.version>
<hamcrest.version>1.3</hamcrest.version> <servlet.version>4.0.3</servlet.version>
<systemRules.version>1.19.0</systemRules.version> <activation.version>1.2.2</activation.version>
<changelog-lib.version>1.59</changelog-lib.version> <junit.version>5.6.0</junit.version>
<bnd.version>5.0.1</bnd.version> <mockito.version>3.3.0</mockito.version>
<hamcrest.version>1.3</hamcrest.version>
<gitlab.version>12.9.2-ce.0</gitlab.version> <systemRules.version>1.19.0</systemRules.version>
<gitlab.autoremove-container>true</gitlab.autoremove-container>
<gitlab.skip-docker-start>true</gitlab.skip-docker-start> <changelog-lib.version>1.59</changelog-lib.version>
<gitlab.port>8090</gitlab.port> <bnd.version>5.3.0</bnd.version>
</properties>
<gitlab.version>12.9.2-ce.0</gitlab.version>
<scm> <gitlab.autoremove-container>true</gitlab.autoremove-container>
<url>git@github.com:gitlab4j/gitlab4j-api.git</url> <gitlab.skip-docker-start>true</gitlab.skip-docker-start>
<connection>scm:git:git@github.com:gitlab4j/gitlab4j-api.git</connection> <gitlab.port>8090</gitlab.port>
<developerConnection>scm:git:git@github.com:gitlab4j/gitlab4j-api.git</developerConnection>
<tag>HEAD</tag> <sonar.projectKey>gitlab4j_gitlab4j-api</sonar.projectKey>
</scm> <sonar.organization>gitlab4j</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<build> </properties>
<defaultGoal>package</defaultGoal>
<plugins> <scm>
<url>git@github.com:gitlab4j/gitlab4j-api.git</url>
<plugin> <connection>scm:git:git@github.com:gitlab4j/gitlab4j-api.git</connection>
<groupId>org.apache.maven.plugins</groupId> <developerConnection>scm:git:git@github.com:gitlab4j/gitlab4j-api.git</developerConnection>
<artifactId>maven-release-plugin</artifactId> <tag>HEAD</tag>
<configuration> </scm>
<goals>deploy</goals>
</configuration> <build>
</plugin> <defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-scm-plugin</artifactId> <plugin>
<version>1.9.5</version> <groupId>org.apache.maven.plugins</groupId>
<configuration> <artifactId>maven-release-plugin</artifactId>
<tag>${project.artifactId}-${project.version}</tag> <configuration>
</configuration> <goals>deploy</goals>
</plugin> </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-scm-plugin</artifactId>
<version>3.7.0</version> <version>1.9.5</version>
<configuration> <configuration>
<source>${java.source.version}</source> <tag>${project.artifactId}-${project.version}</tag>
<target>${java.target.version}</target> </configuration>
</configuration> </plugin>
<executions>
<execution> <plugin>
<id>default-compile</id> <groupId>org.apache.maven.plugins</groupId>
<configuration> <artifactId>maven-compiler-plugin</artifactId>
<excludes> <version>3.7.0</version>
<exclude>**/module-info.java</exclude> <configuration>
</excludes> <source>${java.source.version}</source>
</configuration> <target>${java.target.version}</target>
</execution> </configuration>
</executions> <executions>
</plugin> <execution>
<id>default-compile</id>
<plugin> <configuration>
<groupId>biz.aQute.bnd</groupId> <excludes>
<artifactId>bnd-maven-plugin</artifactId> <exclude>**/module-info.java</exclude>
<executions> </excludes>
<execution> </configuration>
<goals> </execution>
<goal>bnd-process</goal> </executions>
</goals> </plugin>
</execution>
</executions> <plugin>
</plugin> <groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<plugin> <executions>
<groupId>org.apache.maven.plugins</groupId> <execution>
<artifactId>maven-gpg-plugin</artifactId> <goals>
<version>1.6</version> <goal>bnd-process</goal>
<executions> </goals>
<execution> </execution>
<id>sign-artifacts</id> </executions>
<phase>verify</phase> </plugin>
<goals>
<goal>sign</goal> <plugin>
</goals> <groupId>org.apache.maven.plugins</groupId>
</execution> <artifactId>maven-gpg-plugin</artifactId>
</executions> <version>1.6</version>
</plugin> <executions>
<execution>
<plugin> <id>sign-artifacts</id>
<groupId>org.apache.maven.plugins</groupId> <phase>verify</phase>
<artifactId>maven-source-plugin</artifactId> <goals>
<version>3.0.0</version> <goal>sign</goal>
<executions> </goals>
<execution> </execution>
<id>attach-sources</id> </executions>
<goals> </plugin>
<goal>jar-no-fork</goal>
</goals> <plugin>
</execution> <groupId>org.apache.maven.plugins</groupId>
</executions> <artifactId>maven-source-plugin</artifactId>
</plugin> <version>3.0.0</version>
<executions>
<plugin> <execution>
<groupId>org.apache.maven.plugins</groupId> <id>attach-sources</id>
<artifactId>maven-javadoc-plugin</artifactId> <goals>
<version>3.2.0</version> <goal>jar-no-fork</goal>
<configuration> </goals>
<source>8</source> </execution>
</configuration> </executions>
<executions> </plugin>
<execution>
<id>attach-javadocs</id> <plugin>
<goals> <groupId>org.apache.maven.plugins</groupId>
<goal>jar</goal> <artifactId>maven-javadoc-plugin</artifactId>
</goals> <version>3.2.0</version>
</execution> <configuration>
</executions> <source>8</source>
</plugin> </configuration>
<executions>
<plugin> <execution>
<groupId>org.apache.maven.plugins</groupId> <id>attach-javadocs</id>
<artifactId>maven-jar-plugin</artifactId> <goals>
<version>3.2.0</version> <goal>jar</goal>
<configuration> </goals>
<archive> </execution>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> </executions>
</archive> </plugin>
</configuration>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<plugin> <artifactId>maven-jar-plugin</artifactId>
<groupId>org.jacoco</groupId> <version>3.2.0</version>
<artifactId>jacoco-maven-plugin</artifactId> <configuration>
<version>0.8.3</version> <archive>
<executions> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<execution> </archive>
<id>default-prepare-agent</id> </configuration>
<goals> </plugin>
<goal>prepare-agent</goal>
</goals> <plugin>
</execution> <groupId>org.jacoco</groupId>
<execution> <artifactId>jacoco-maven-plugin</artifactId>
<id>default-report</id> <version>0.8.3</version>
<phase>prepare-package</phase> <executions>
<goals> <execution>
<goal>report</goal> <id>default-prepare-agent</id>
</goals> <goals>
</execution> <goal>prepare-agent</goal>
<execution> </goals>
<id>default-check</id> </execution>
<goals> <execution>
<goal>check</goal> <id>default-report</id>
</goals> <phase>prepare-package</phase>
<configuration> <goals>
<rules> <goal>report</goal>
<!-- implementation is needed only for Maven 2 --> </goals>
<rule implementation="org.jacoco.maven.RuleConfiguration"> </execution>
<element>BUNDLE</element> <execution>
<limits> <id>default-check</id>
<!-- implementation is needed only for Maven 2 --> <goals>
<limit implementation="org.jacoco.report.check.Limit"> <goal>check</goal>
<counter>COMPLEXITY</counter> </goals>
<value>COVEREDRATIO</value> <configuration>
<minimum>0.40</minimum> <rules>
</limit> <!-- implementation is needed only for Maven 2 -->
</limits> <rule implementation="org.jacoco.maven.RuleConfiguration">
</rule> <element>BUNDLE</element>
</rules> <limits>
</configuration> <!-- implementation is needed only for Maven 2 -->
</execution> <limit implementation="org.jacoco.report.check.Limit">
</executions> <counter>COMPLEXITY</counter>
</plugin> <value>COVEREDRATIO</value>
<minimum>0.40</minimum>
<plugin> </limit>
<groupId>org.apache.maven.plugins</groupId> </limits>
<artifactId>maven-surefire-plugin</artifactId> </rule>
<version>3.0.0-M3</version> </rules>
<configuration> </configuration>
<excludedGroups>org.gitlab4j.api.IntegrationTest</excludedGroups> </execution>
<systemPropertyVariables> </executions>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile> </plugin>
</systemPropertyVariables>
</configuration> <plugin>
</plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<plugin> <version>3.0.0-M3</version>
<groupId>org.apache.maven.plugins</groupId> <configuration>
<artifactId>maven-failsafe-plugin</artifactId> <excludedGroups>org.gitlab4j.api.IntegrationTest</excludedGroups>
<version>3.0.0-M3</version> <systemPropertyVariables>
<configuration> <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
<groups>org.gitlab4j.api.IntegrationTest</groups> </systemPropertyVariables>
<includes> </configuration>
<include>**/IntegrationTestSuite.java</include> </plugin>
</includes>
</configuration> <plugin>
<executions> <groupId>org.apache.maven.plugins</groupId>
<execution> <artifactId>maven-failsafe-plugin</artifactId>
<goals> <version>3.0.0-M3</version>
<goal>integration-test</goal> <configuration>
<goal>verify</goal> <groups>org.gitlab4j.api.IntegrationTest</groups>
</goals> <includes>
</execution> <include>**/IntegrationTestSuite.java</include>
</executions> </includes>
</plugin> </configuration>
<executions>
<plugin> <execution>
<groupId>org.apache.maven.plugins</groupId> <goals>
<artifactId>maven-enforcer-plugin</artifactId> <goal>integration-test</goal>
<version>3.0.0-M2</version> <goal>verify</goal>
<configuration> </goals>
<rules> </execution>
<enforceBytecodeVersion> </executions>
<maxJdkVersion>1.8</maxJdkVersion> </plugin>
<ignoreClasses>
<ignoreClass>module-info</ignoreClass> <plugin>
</ignoreClasses> <groupId>org.apache.maven.plugins</groupId>
</enforceBytecodeVersion> <artifactId>maven-enforcer-plugin</artifactId>
</rules> <version>3.0.0-M2</version>
</configuration> <configuration>
<executions> <rules>
<execution> <enforceBytecodeVersion>
<id>enforce-bytecode-version</id> <maxJdkVersion>1.8</maxJdkVersion>
<goals> <ignoreClasses>
<goal>enforce</goal> <ignoreClass>module-info</ignoreClass>
</goals> </ignoreClasses>
</execution> </enforceBytecodeVersion>
</executions> </rules>
<dependencies> </configuration>
<dependency> <executions>
<groupId>org.codehaus.mojo</groupId> <execution>
<artifactId>extra-enforcer-rules</artifactId> <id>enforce-bytecode-version</id>
<version>1.2</version> <goals>
</dependency> <goal>enforce</goal>
</dependencies> </goals>
</plugin> </execution>
</executions>
<plugin> <dependencies>
<groupId>org.codehaus.mojo</groupId> <dependency>
<artifactId>animal-sniffer-maven-plugin</artifactId> <groupId>org.codehaus.mojo</groupId>
<version>1.17</version> <artifactId>extra-enforcer-rules</artifactId>
<executions> <version>1.2</version>
<execution> </dependency>
<goals> </dependencies>
<goal>check</goal> </plugin>
</goals>
<id>check</id> <plugin>
</execution> <groupId>org.codehaus.mojo</groupId>
</executions> <artifactId>animal-sniffer-maven-plugin</artifactId>
<configuration> <version>1.17</version>
<signature> <executions>
<groupId>org.codehaus.mojo.signature</groupId> <execution>
<artifactId>java1${java.level}</artifactId> <goals>
</signature> <goal>check</goal>
</configuration> </goals>
</plugin> <id>check</id>
</execution>
<plugin> </executions>
<groupId>io.fabric8</groupId> <configuration>
<artifactId>docker-maven-plugin</artifactId> <signature>
<version>0.30.0</version> <groupId>org.codehaus.mojo.signature</groupId>
<configuration> <artifactId>java1${java.level}</artifactId>
<images> </signature>
<image> </configuration>
<name>gitlab/gitlab-ce:${gitlab.version}</name> </plugin>
<alias>gitlab</alias>
<run> <plugin>
<skip>${gitlab.skip-docker-start}</skip> <groupId>io.fabric8</groupId>
<env> <artifactId>docker-maven-plugin</artifactId>
<GITLAB_OMNIBUS_CONFIG>gitlab_rails['initial_root_password']="password"; gitlab_rails['lfs_enabled']=false;</GITLAB_OMNIBUS_CONFIG> <version>0.30.0</version>
</env> <configuration>
<ports> <images>
<port>${gitlab.port}:80</port> <image>
</ports> <name>gitlab/gitlab-ce:${gitlab.version}</name>
<wait> <alias>gitlab</alias>
<healthy>true</healthy> <run>
<time>300000</time> <skip>${gitlab.skip-docker-start}</skip>
</wait> <env>
</run> <GITLAB_OMNIBUS_CONFIG>gitlab_rails['initial_root_password']="password"; gitlab_rails['lfs_enabled']=false;</GITLAB_OMNIBUS_CONFIG>
</image> </env>
</images> <ports>
<removeVolumes>true</removeVolumes> <port>${gitlab.port}:80</port>
</configuration> </ports>
<executions> <wait>
<execution> <healthy>true</healthy>
<id>start</id> <time>300000</time>
<phase>pre-integration-test</phase> </wait>
<goals> </run>
<goal>start</goal> </image>
</goals> </images>
</execution> <removeVolumes>true</removeVolumes>
<execution> </configuration>
<id>stop</id> <executions>
<phase>post-integration-test</phase> <execution>
<goals> <id>start</id>
<goal>stop</goal> <phase>pre-integration-test</phase>
</goals> <goals>
</execution> <goal>start</goal>
</executions> </goals>
</plugin> </execution>
<execution>
</plugins> <id>stop</id>
<phase>post-integration-test</phase>
<pluginManagement> <goals>
<plugins> <goal>stop</goal>
<!-- The se.bjurr.gitchangelog:git-changelog-maven-plugin needs to be in --> </goals>
<!-- this section (pluginManagement) for it to work correctly. --> </execution>
<plugin> </executions>
<groupId>se.bjurr.gitchangelog</groupId> </plugin>
<artifactId>git-changelog-maven-plugin</artifactId>
<version>${changelog-lib.version}</version> </plugins>
<executions>
<execution> <pluginManagement>
<goals> <plugins>
<goal>git-changelog</goal> <!-- The se.bjurr.gitchangelog:git-changelog-maven-plugin needs to be in -->
</goals> <!-- this section (pluginManagement) for it to work correctly. -->
<configuration> <plugin>
<readableTagName>gitlab4j-api-(.*)</readableTagName> <groupId>se.bjurr.gitchangelog</groupId>
<templateFile>CHANGELOG.mustache</templateFile> <artifactId>git-changelog-maven-plugin</artifactId>
</configuration> <version>${changelog-lib.version}</version>
</execution> <executions>
</executions> <execution>
</plugin> <goals>
<plugin> <goal>git-changelog</goal>
<groupId>biz.aQute.bnd</groupId> </goals>
<artifactId>bnd-maven-plugin</artifactId> <configuration>
<version>${bnd.version}</version> <readableTagName>gitlab4j-api-(.*)</readableTagName>
<configuration> <templateFile>CHANGELOG.mustache</templateFile>
<bnd><![CDATA[ </configuration>
Export-Package: org.gitlab4j.api.* </execution>
]]></bnd> </executions>
</configuration> </plugin>
</plugin> <plugin>
</plugins> <groupId>biz.aQute.bnd</groupId>
</pluginManagement> <artifactId>bnd-maven-plugin</artifactId>
</build> <version>${bnd.version}</version>
<configuration>
<dependencies> <bnd><![CDATA[
Export-Package: org.gitlab4j.api.*
<!-- javax.activation is present for Java 9+ compatibility --> ]]></bnd>
<dependency> </configuration>
<groupId>jakarta.activation</groupId> </plugin>
<artifactId>jakarta.activation-api</artifactId> </plugins>
<version>${activation.version}</version> </pluginManagement>
</dependency> </build>
<dependency> <dependencies>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId> <!-- javax.activation is present for Java 9+ compatibility -->
<version>${jackson.version}</version> <dependency>
</dependency> <groupId>jakarta.activation</groupId>
<dependency> <artifactId>jakarta.activation-api</artifactId>
<groupId>org.glassfish.jersey.inject</groupId> <version>${activation.version}</version>
<artifactId>jersey-hk2</artifactId> </dependency>
<version>${jersey.version}</version>
</dependency> <dependency>
<dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId>
<groupId>org.glassfish.jersey.core</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId>
<artifactId>jersey-client</artifactId> <version>${jackson.version}</version>
<version>${jersey.version}</version> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.glassfish.jersey.inject</groupId>
<groupId>org.glassfish.jersey.connectors</groupId> <artifactId>jersey-hk2</artifactId>
<artifactId>jersey-apache-connector</artifactId> <version>${jersey.version}</version>
<version>${jersey.version}</version> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.glassfish.jersey.core</groupId>
<groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-client</artifactId>
<artifactId>jersey-media-multipart</artifactId> <version>${jersey.version}</version>
<version>${jersey.version}</version> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.glassfish.jersey.connectors</groupId>
<groupId>jakarta.servlet</groupId> <artifactId>jersey-apache-connector</artifactId>
<artifactId>jakarta.servlet-api</artifactId> <version>${jersey.version}</version>
<version>${servlet.version}</version> </dependency>
</dependency> <dependency>
<groupId>org.glassfish.jersey.media</groupId>
<dependency> <artifactId>jersey-media-multipart</artifactId>
<groupId>org.junit.vintage</groupId> <version>${jersey.version}</version>
<artifactId>junit-vintage-engine</artifactId> </dependency>
<version>${junit.version}</version> <dependency>
<scope>test</scope> <groupId>jakarta.servlet</groupId>
</dependency> <artifactId>jakarta.servlet-api</artifactId>
<dependency> <version>${servlet.version}</version>
<groupId>org.mockito</groupId> </dependency>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version> <dependency>
<scope>test</scope> <groupId>org.junit.vintage</groupId>
</dependency> <artifactId>junit-vintage-engine</artifactId>
<dependency> <version>${junit.version}</version>
<groupId>org.hamcrest</groupId> <scope>test</scope>
<artifactId>hamcrest-all</artifactId> </dependency>
<version>${hamcrest.version}</version> <dependency>
<scope>test</scope> <groupId>org.mockito</groupId>
</dependency> <artifactId>mockito-core</artifactId>
<dependency> <version>${mockito.version}</version>
<groupId>com.github.stefanbirkner</groupId> <scope>test</scope>
<artifactId>system-rules</artifactId> </dependency>
<version>${systemRules.version}</version> <dependency>
<scope>test</scope> <groupId>org.hamcrest</groupId>
</dependency> <artifactId>hamcrest-all</artifactId>
<dependency> <version>${hamcrest.version}</version>
<groupId>com.googlecode.junit-toolbox</groupId> <scope>test</scope>
<artifactId>junit-toolbox</artifactId> </dependency>
<version>2.4</version> <dependency>
<scope>test</scope> <groupId>com.github.stefanbirkner</groupId>
</dependency> <artifactId>system-rules</artifactId>
</dependencies> <version>${systemRules.version}</version>
<scope>test</scope>
<dependencyManagement> </dependency>
<dependencies> <dependency>
<!-- Needed for animal-sniffer --> <groupId>com.googlecode.junit-toolbox</groupId>
<dependency> <artifactId>junit-toolbox</artifactId>
<groupId>org.codehaus.mojo.signature</groupId> <version>2.4</version>
<artifactId>java18</artifactId> <scope>test</scope>
<version>1.0</version> </dependency>
<type>signature</type> </dependencies>
</dependency>
</dependencies> <dependencyManagement>
</dependencyManagement> <dependencies>
<!-- Needed for animal-sniffer -->
</project> <dependency>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
<version>1.0</version>
<type>signature</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>
...@@ -243,6 +243,28 @@ public interface Constants { ...@@ -243,6 +243,28 @@ public interface Constants {
} }
} }
/** Enum to use for ordering the results of getDeployments. */
public static enum DeploymentOrderBy {
ID, IID, CREATED_AT, UPDATED_AT, REF;
private static JacksonJsonEnumHelper<DeploymentOrderBy> enumHelper = new JacksonJsonEnumHelper<>(DeploymentOrderBy.class);
@JsonCreator
public static DeploymentOrderBy forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
/** Enum to use for specifying the scope when calling getPipelines(). */ /** Enum to use for specifying the scope when calling getPipelines(). */
public enum PipelineScope { public enum PipelineScope {
...@@ -783,7 +805,9 @@ public interface Constants { ...@@ -783,7 +805,9 @@ public interface Constants {
/** Enum to use for specifying the status of a deployment. */ /** Enum to use for specifying the status of a deployment. */
public enum DeploymentStatus { public enum DeploymentStatus {
/**
* After some tests, {@link #CREATED} value is not a valid value.
*/
CREATED, RUNNING, SUCCESS, FAILED, CANCELED; CREATED, RUNNING, SUCCESS, FAILED, CANCELED;
private static JacksonJsonEnumHelper<DeploymentStatus> enumHelper = new JacksonJsonEnumHelper<>(DeploymentStatus.class); private static JacksonJsonEnumHelper<DeploymentStatus> enumHelper = new JacksonJsonEnumHelper<>(DeploymentStatus.class);
...@@ -848,5 +872,26 @@ public interface Constants { ...@@ -848,5 +872,26 @@ public interface Constants {
return (enumHelper.toString(this)); return (enumHelper.toString(this));
} }
} }
enum AutoDevopsDeployStrategy {
CONTINUOUS, MANUAL, TIMED_INCREMENTAL;
private static JacksonJsonEnumHelper<AutoDevopsDeployStrategy> enumHelper = new JacksonJsonEnumHelper<>(AutoDevopsDeployStrategy.class);
@JsonCreator
public static AutoDevopsDeployStrategy forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
} }
package org.gitlab4j.api;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.models.Deployment;
import org.gitlab4j.api.models.DeploymentFilter;
import org.gitlab4j.api.models.MergeRequest;
/**
* This class implements the client side API for the GitLab Deployments API calls.
* See https://docs.gitlab.com/ee/api/deployments.html
*
*/
public class DeploymentsApi extends AbstractApi {
public DeploymentsApi(GitLabApi gitLabApi) {
super(gitLabApi);
}
/**
* Get a list of deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of Deployments
* @throws GitLabApiException if any exception occurs
*/
public List<Deployment> getProjectDeployments(Object projectIdOrPath) throws GitLabApiException {
return (getProjectDeployments(projectIdOrPath, null, getDefaultPerPage()).all());
}
/**
* Get a Pager of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of Deployments instances that will be fetched per page
* @return a Pager of Deployment
* @throws GitLabApiException if any exception occurs
*/
public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
return (getProjectDeployments(projectIdOrPath, null, itemsPerPage));
}
/**
* Get a Pager of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link DeploymentFilter} a DeploymentFilter instance with the filter settings
* @return a Pager of Deployment
* @throws GitLabApiException if any exception occurs
*/
public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter) throws GitLabApiException {
return (getProjectDeployments(projectIdOrPath, filter, getDefaultPerPage()));
}
/**
* Get a Pager of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link DeploymentFilter} a DeploymentFilter instance with the filter settings
* @param itemsPerPage the number of Deployments instances that will be fetched per page
* @return a Pager of Deployment
* @throws GitLabApiException if any exception occurs
*/
public Pager<Deployment> getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter, int itemsPerPage) throws GitLabApiException {
GitLabApiForm formData = (filter != null ? filter.getQueryParams() : new GitLabApiForm());
return (new Pager<Deployment>(this, Deployment.class, itemsPerPage, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "deployments"));
}
/**
* Get a Stream of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of Deployment
* @throws GitLabApiException if any exception occurs
*/
public Stream<Deployment> getProjectDeploymentsStream(Object projectIdOrPath) throws GitLabApiException {
return (getProjectDeployments(projectIdOrPath, null, getDefaultPerPage()).stream());
}
/**
* Get a Stream of all deployments for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param filter {@link DeploymentFilter} a DeploymentFilter instance with the filter settings
* @return a list of Deployment
* @throws GitLabApiException if any exception occurs
*/
public Stream<Deployment> getProjectDeploymentsStream(Object projectIdOrPath, DeploymentFilter filter) throws GitLabApiException {
return (getProjectDeployments(projectIdOrPath, filter, getDefaultPerPage()).stream());
}
/**
* Get a specific deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId the ID of a project's deployment
* @return the specified Deployment instance
* @throws GitLabApiException if any exception occurs
*/
public Deployment getDeployment(Object projectIdOrPath, Integer deploymentId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
"projects", getProjectIdOrPath(projectIdOrPath), "deployments", deploymentId);
return (response.readEntity(Deployment.class));
}
/**
* Get a specific deployment as an Optional instance.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId the ID of a project's deployment
* @return the specified Deployment as an Optional instance
*/
public Optional<Deployment> getOptionalDeployment(Object projectIdOrPath, Integer deploymentId) {
try {
return (Optional.ofNullable(getDeployment(projectIdOrPath, deploymentId)));
} catch (GitLabApiException glae) {
return (GitLabApi.createOptionalFromException(glae));
}
}
/**
* Creates a new deployment for a project.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/deployments</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param environment The name of the environment to create the deployment for, required
* @param sha The SHA of the commit that is deployed, required
* @param ref The name of the branch or tag that is deployed, required
* @param tag A boolean that indicates if the deployed ref is a tag (true) or not (false), required
* @param status The status to filter deployments by, required
* @return a Deployment instance with info on the added deployment
* @throws GitLabApiException if any exception occurs
*/
public Deployment addDeployment(Object projectIdOrPath, String environment, String sha, String ref, Boolean tag, DeploymentStatus status) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("environment", environment, true)
.withParam("sha", sha, true)
.withParam("ref", ref, true)
.withParam("tag", tag, true)
.withParam("status", status, true);
Response response = post(Response.Status.CREATED, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "deployments");
return (response.readEntity(Deployment.class));
}
/**
* Updates an existing project deploy key.
*
* <pre><code>GitLab Endpoint: PUT /projects/:id/deployments/:key_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @param status The new status of the deployment, required
* @return an updated Deployment instance
* @throws GitLabApiException if any exception occurs
*/
public Deployment updateDeployment(Object projectIdOrPath, Integer deploymentId, DeploymentStatus status) throws GitLabApiException {
if (deploymentId == null) {
throw new RuntimeException("deploymentId cannot be null");
}
final Deployment deployment = new Deployment();
deployment.setStatus(status);
final Response response = put(Response.Status.OK, deployment,
"projects", getProjectIdOrPath(projectIdOrPath), "deployments", deploymentId);
return (response.readEntity(Deployment.class));
}
/**
* Get a list of Merge Requests shipped with a given deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @return a list containing the MergeRequest instances shipped with a given deployment
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public List<MergeRequest> getMergeRequests(Object projectIdOrPath, Integer deploymentId) throws GitLabApiException {
return (getMergeRequests(projectIdOrPath, deploymentId, getDefaultPerPage()).all());
}
/**
* Get a Pager of Merge Requests shipped with a given deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @param itemsPerPage the number of Commit instances that will be fetched per page
* @return a Pager containing the MergeRequest instances shipped with a given deployment
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public Pager<MergeRequest> getMergeRequests(Object projectIdOrPath, Integer deploymentId, int itemsPerPage) throws GitLabApiException {
return (new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, null,
"projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", deploymentId, "merge_requests"));
}
/**
* Get a Stream of Merge Requests shipped with a given deployment.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deployments/:deployment_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deploymentId The ID of the deployment to update, required
* @return a Stream containing the MergeRequest instances shipped with a given deployment
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public Stream<MergeRequest> getMergeRequestsStream(Object projectIdOrPath, Integer deploymentId) throws GitLabApiException {
return (getMergeRequests(projectIdOrPath, deploymentId, getDefaultPerPage()).stream());
}
}
...@@ -603,7 +603,7 @@ public class DiscussionsApi extends AbstractApi { ...@@ -603,7 +603,7 @@ public class DiscussionsApi extends AbstractApi {
public void deleteCommitDiscussionNote(Object projectIdOrPath, String commitSha, public void deleteCommitDiscussionNote(Object projectIdOrPath, String commitSha,
String discussionId, Integer noteId) throws GitLabApiException { String discussionId, Integer noteId) throws GitLabApiException {
delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath),
"repository", commitSha, "discussions", discussionId, "notes", noteId); "repository", "commits", commitSha, "discussions", discussionId, "notes", noteId);
} }
/** /**
......
...@@ -58,6 +58,7 @@ public class GitLabApi implements AutoCloseable { ...@@ -58,6 +58,7 @@ public class GitLabApi implements AutoCloseable {
private ContainerRegistryApi containerRegistryApi; private ContainerRegistryApi containerRegistryApi;
private DiscussionsApi discussionsApi; private DiscussionsApi discussionsApi;
private DeployKeysApi deployKeysApi; private DeployKeysApi deployKeysApi;
private DeploymentsApi deploymentsApi;
private DeployTokensApi deployTokensApi; private DeployTokensApi deployTokensApi;
private EnvironmentsApi environmentsApi; private EnvironmentsApi environmentsApi;
private EpicsApi epicsApi; private EpicsApi epicsApi;
...@@ -961,6 +962,25 @@ public class GitLabApi implements AutoCloseable { ...@@ -961,6 +962,25 @@ public class GitLabApi implements AutoCloseable {
return (deployKeysApi); return (deployKeysApi);
} }
/**
* Gets the DeployKeysApi instance owned by this GitLabApi instance. The DeploymentsApi is used
* to perform all deployment related API calls.
*
* @return the DeploymentsApi instance owned by this GitLabApi instance
*/
public DeploymentsApi getDeploymentsApi() {
if (deploymentsApi == null) {
synchronized (this) {
if (deploymentsApi == null) {
deploymentsApi = new DeploymentsApi(this);
}
}
}
return (deploymentsApi);
}
/** /**
* Gets the DeployTokensApi instance owned by this GitLabApi instance. The DeployTokensApi is used * Gets the DeployTokensApi instance owned by this GitLabApi instance. The DeployTokensApi is used
* to perform all deploy token related API calls. * to perform all deploy token related API calls.
......
...@@ -1310,9 +1310,28 @@ public class GroupApi extends AbstractApi { ...@@ -1310,9 +1310,28 @@ public class GroupApi extends AbstractApi {
*/ */
public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException { public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException {
return createVariable(groupIdOrPath, key, value, isProtected, false);
}
/**
* Create a new group variable.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/variables</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param key the key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed, required
* @param value the value for the variable, required
* @param isProtected whether the variable is protected, optional
* @param masked whether the variable is masked, optional
* @return a Variable instance with the newly created variable
* @throws GitLabApiException if any exception occurs during execution
*/
public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected, Boolean masked) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("key", key, true) .withParam("key", key, true)
.withParam("value", value, true) .withParam("value", value, true)
.withParam("masked", masked)
.withParam("protected", isProtected); .withParam("protected", isProtected);
Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables"); Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables");
return (response.readEntity(Variable.class)); return (response.readEntity(Variable.class));
...@@ -1332,8 +1351,27 @@ public class GroupApi extends AbstractApi { ...@@ -1332,8 +1351,27 @@ public class GroupApi extends AbstractApi {
*/ */
public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException { public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException {
return updateVariable(groupIdOrPath, key, value, isProtected, false);
}
/**
* Update a group variable.
*
* <pre><code>GitLab Endpoint: PUT /groups/:id/variables/:key</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param key the key of an existing variable, required
* @param value the value for the variable, required
* @param isProtected whether the variable is protected, optional
* @param masked whether the variable is masked, optional
* @return a Variable instance with the updated variable
* @throws GitLabApiException if any exception occurs during execution
*/
public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected, Boolean masked) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("value", value, true) .withParam("value", value, true)
.withParam("masked", masked)
.withParam("protected", isProtected); .withParam("protected", isProtected);
Response response = putWithFormData(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); Response response = putWithFormData(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key);
return (response.readEntity(Variable.class)); return (response.readEntity(Variable.class));
......
...@@ -306,12 +306,6 @@ public class Pager<T> implements Iterator<List<T>>, Constants { ...@@ -306,12 +306,6 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
*/ */
public List<T> page(int pageNumber) { public List<T> page(int pageNumber) {
if (pageNumber > totalPages && pageNumber > kaminariNextPage) {
throw new NoSuchElementException();
} else if (pageNumber < 1) {
throw new NoSuchElementException();
}
if (currentPage == 0 && pageNumber == 1) { if (currentPage == 0 && pageNumber == 1) {
currentPage = 1; currentPage = 1;
return (currentItems); return (currentItems);
...@@ -321,6 +315,12 @@ public class Pager<T> implements Iterator<List<T>>, Constants { ...@@ -321,6 +315,12 @@ public class Pager<T> implements Iterator<List<T>>, Constants {
return (currentItems); return (currentItems);
} }
if (pageNumber > totalPages && pageNumber > kaminariNextPage) {
throw new NoSuchElementException();
} else if (pageNumber < 1) {
throw new NoSuchElementException();
}
try { try {
setPageParam(pageNumber); setPageParam(pageNumber);
......
...@@ -30,8 +30,10 @@ class PagerSpliterator<T> implements Spliterator<T> { ...@@ -30,8 +30,10 @@ class PagerSpliterator<T> implements Spliterator<T> {
return true; return true;
} else if (pager.hasNext()) { } else if (pager.hasNext()) {
elements = pager.next().iterator(); elements = pager.next().iterator();
action.accept(elements.next()); if(elements.hasNext()) {
return true; action.accept(elements.next());
return true;
}
} }
return false; return false;
} }
......
...@@ -1022,7 +1022,9 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1022,7 +1022,9 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("initialize_with_readme", project.getInitializeWithReadme()) .withParam("initialize_with_readme", project.getInitializeWithReadme())
.withParam("packages_enabled", project.getPackagesEnabled()) .withParam("packages_enabled", project.getPackagesEnabled())
.withParam("build_git_strategy", project.getBuildGitStrategy()) .withParam("build_git_strategy", project.getBuildGitStrategy())
.withParam("build_coverage_regex", project.getBuildCoverageRegex()); .withParam("build_coverage_regex", project.getBuildCoverageRegex())
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge());
Namespace namespace = project.getNamespace(); Namespace namespace = project.getNamespace();
if (namespace != null && namespace.getId() != null) { if (namespace != null && namespace.getId() != null) {
...@@ -1046,10 +1048,6 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1046,10 +1048,6 @@ public class ProjectApi extends AbstractApi implements Constants {
} }
} }
if (project.getNamespace() != null) {
formData.withParam("namespace_id", project.getNamespace().getId());
}
Response response = post(Response.Status.CREATED, formData, "projects"); Response response = post(Response.Status.CREATED, formData, "projects");
return (response.readEntity(Project.class)); return (response.readEntity(Project.class));
} }
...@@ -1269,7 +1267,10 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -1269,7 +1267,10 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("resolve_outdated_diff_discussions", project.getResolveOutdatedDiffDiscussions()) .withParam("resolve_outdated_diff_discussions", project.getResolveOutdatedDiffDiscussions())
.withParam("packages_enabled", project.getPackagesEnabled()) .withParam("packages_enabled", project.getPackagesEnabled())
.withParam("build_git_strategy", project.getBuildGitStrategy()) .withParam("build_git_strategy", project.getBuildGitStrategy())
.withParam("build_coverage_regex", project.getBuildCoverageRegex()); .withParam("build_coverage_regex", project.getBuildCoverageRegex())
.withParam("merge_method", project.getMergeMethod())
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge());
if (isApiVersion(ApiVersion.V3)) { if (isApiVersion(ApiVersion.V3)) {
formData.withParam("visibility_level", project.getVisibilityLevel()); formData.withParam("visibility_level", project.getVisibilityLevel());
...@@ -2065,7 +2066,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -2065,7 +2066,7 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("confidential_note_events", enabledHooks.getConfidentialNoteEvents(), false) .withParam("confidential_note_events", enabledHooks.getConfidentialNoteEvents(), false)
.withParam("job_events", enabledHooks.getJobEvents(), false) .withParam("job_events", enabledHooks.getJobEvents(), false)
.withParam("pipeline_events", enabledHooks.getPipelineEvents(), false) .withParam("pipeline_events", enabledHooks.getPipelineEvents(), false)
.withParam("wiki_events", enabledHooks.getWikiPageEvents(), false) .withParam("wiki_page_events", enabledHooks.getWikiPageEvents(), false)
.withParam("enable_ssl_verification", enableSslVerification, false) .withParam("enable_ssl_verification", enableSslVerification, false)
.withParam("repository_update_events", enabledHooks.getRepositoryUpdateEvents(), false) .withParam("repository_update_events", enabledHooks.getRepositoryUpdateEvents(), false)
.withParam("token", secretToken, false); .withParam("token", secretToken, false);
...@@ -2145,7 +2146,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -2145,7 +2146,7 @@ public class ProjectApi extends AbstractApi implements Constants {
.withParam("note_events", hook.getNoteEvents(), false) .withParam("note_events", hook.getNoteEvents(), false)
.withParam("job_events", hook.getJobEvents(), false) .withParam("job_events", hook.getJobEvents(), false)
.withParam("pipeline_events", hook.getPipelineEvents(), false) .withParam("pipeline_events", hook.getPipelineEvents(), false)
.withParam("wiki_events", hook.getWikiPageEvents(), false) .withParam("wiki_page_events", hook.getWikiPageEvents(), false)
.withParam("enable_ssl_verification", hook.getEnableSslVerification(), false) .withParam("enable_ssl_verification", hook.getEnableSslVerification(), false)
.withParam("token", hook.getToken(), false); .withParam("token", hook.getToken(), false);
......
...@@ -18,6 +18,7 @@ import javax.ws.rs.core.Response; ...@@ -18,6 +18,7 @@ import javax.ws.rs.core.Response;
import org.gitlab4j.api.GitLabApi.ApiVersion; import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.ChangelogPayload;
import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.CompareResults; import org.gitlab4j.api.models.CompareResults;
import org.gitlab4j.api.models.Contributor; import org.gitlab4j.api.models.Contributor;
...@@ -749,4 +750,32 @@ public class RepositoryApi extends AbstractApi { ...@@ -749,4 +750,32 @@ public class RepositoryApi extends AbstractApi {
delete(Response.Status.NO_CONTENT, null, "projects", delete(Response.Status.NO_CONTENT, null, "projects",
getProjectIdOrPath(projectIdOrPath), "repository", "merged_branches"); getProjectIdOrPath(projectIdOrPath), "repository", "merged_branches");
} }
/**
* Generate changelog data based on commits in a repository.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/changelog</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param version the version to generate the changelog for
* @throws GitLabApiException if any exception occurs
*/
public void generateChangelog(Object projectIdOrPath, String version) throws GitLabApiException {
generateChangelog(projectIdOrPath, new ChangelogPayload(version));
}
/**
* Generate changelog data based on commits in a repository.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/changelog</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param payload the payload to generate the changelog for
* @throws GitLabApiException if any exception occurs
*/
public void generateChangelog(Object projectIdOrPath, ChangelogPayload payload) throws GitLabApiException {
post(Response.Status.OK, payload.getFormData(), "projects",
getProjectIdOrPath(projectIdOrPath), "repository", "changelog");
}
} }
...@@ -3,6 +3,7 @@ package org.gitlab4j.api; ...@@ -3,6 +3,7 @@ package org.gitlab4j.api;
import org.gitlab4j.api.GitLabApi.ApiVersion; import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.services.BugzillaService; import org.gitlab4j.api.services.BugzillaService;
import org.gitlab4j.api.services.CustomIssueTrackerService; import org.gitlab4j.api.services.CustomIssueTrackerService;
import org.gitlab4j.api.services.EmailOnPushService;
import org.gitlab4j.api.services.ExternalWikiService; import org.gitlab4j.api.services.ExternalWikiService;
import org.gitlab4j.api.services.HipChatService; import org.gitlab4j.api.services.HipChatService;
import org.gitlab4j.api.services.JiraService; import org.gitlab4j.api.services.JiraService;
...@@ -493,4 +494,60 @@ public class ServicesApi extends AbstractApi { ...@@ -493,4 +494,60 @@ public class ServicesApi extends AbstractApi {
delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "custom-issue-tracker"); delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "custom-issue-tracker");
} }
/**
* Get Emails on push service settings for a project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/services/emails-on-push</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @return a EmailOnPushService instance holding the Email on push settings
* @throws GitLabApiException if any exception occurs
*/
public EmailOnPushService getEmailOnPushService(Object projectIdOrPath) throws GitLabApiException {
Response response = this.get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "emails-on-push");
return (response.readEntity(EmailOnPushService.class));
}
/**
* Updates the EmailsOnPush service settings for a project.
*
* <pre><code>GitLab Endpoint: PUT /projects/:id/services/emails-on-push</code></pre>
*
* The following properties on the EmailOnPushService instance are utilized in the update of the settings:
* <p>
* recipients (required), Emails separated by whitespace
* disable_diffs (optional), Disable code diffs
* send_from_committer_email (optional), Send from committer
* push_events (optional), Enable notifications for push events
* tag_push_events(optional), Enable notifications for tag push events
* branches_to_be_notified (optional), Branches to send notifications for. Valid options are "all", "default",
* "protected", and "default_and_protected". Notifications are always fired
* for tag pushes. The default value is "all"
* </p>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param emailsOnPush the EmailOnPushService instance holding the settings
* @return a EmailOnPushService instance holding the newly updated settings
* @throws GitLabApiException if any exception occurs
*/
public EmailOnPushService updateEmailOnPushService(Object projectIdOrPath, EmailOnPushService emailsOnPush) throws GitLabApiException {
GitLabApiForm formData = emailsOnPush.servicePropertiesForm();
Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "services", "emails-on-push");
return (response.readEntity(EmailOnPushService.class));
}
/**
* Deletes the Emails on push service for a project.
*
* <pre><code>GitLab Endpoint: DELETE /projects/:id/services/emails-on-push</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @throws GitLabApiException if any exception occurs
*/
public void deleteEmailonPushService(Object projectIdOrPath) throws GitLabApiException {
delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "emails-on-push");
}
} }
...@@ -80,12 +80,32 @@ public class SystemHooksApi extends AbstractApi { ...@@ -80,12 +80,32 @@ public class SystemHooksApi extends AbstractApi {
* @param token secret token to validate received payloads, optional * @param token secret token to validate received payloads, optional
* @param pushEvents when true, the hook will fire on push events, optional * @param pushEvents when true, the hook will fire on push events, optional
* @param tagPushEvents when true, the hook will fire on new tags being pushed, optional * @param tagPushEvents when true, the hook will fire on new tags being pushed, optional
* @param enablSsslVerification do SSL verification when triggering the hook, optional * @param enableSslVerification do SSL verification when triggering the hook, optional
* @return an SystemHookEvent instance with info on the added system hook * @return an SystemHookEvent instance with info on the added system hook
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public SystemHook addSystemHook(String url, String token, Boolean pushEvents, public SystemHook addSystemHook(String url, String token, Boolean pushEvents,
Boolean tagPushEvents, Boolean enablSsslVerification) throws GitLabApiException { Boolean tagPushEvents, Boolean enableSslVerification) throws GitLabApiException {
SystemHook systemHook = new SystemHook().withPushEvents(pushEvents)
.withTagPushEvents(tagPushEvents)
.withEnableSslVerification(enableSslVerification);
return addSystemHook(url, token, systemHook);
}
/**
* Add a new system hook. This method requires admin access.
*
* <pre><code>GitLab Endpoint: POST /hooks</code></pre>
*
* @param url the hook URL, required
* @param token secret token to validate received payloads, optional
* @param systemHook the systemHook to create
* @return an SystemHookEvent instance with info on the added system hook
* @throws GitLabApiException if any exception occurs
*/
public SystemHook addSystemHook(String url, String token, SystemHook systemHook) throws GitLabApiException {
if (url == null) { if (url == null) {
throw new RuntimeException("url cannot be null"); throw new RuntimeException("url cannot be null");
...@@ -94,9 +114,11 @@ public class SystemHooksApi extends AbstractApi { ...@@ -94,9 +114,11 @@ public class SystemHooksApi extends AbstractApi {
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("url", url, true) .withParam("url", url, true)
.withParam("token", token) .withParam("token", token)
.withParam("push_events", pushEvents) .withParam("push_events", systemHook.getPushEvents())
.withParam("tag_push_events", tagPushEvents) .withParam("tag_push_events", systemHook.getTagPushEvents())
.withParam("enable_ssl_verification", enablSsslVerification); .withParam("merge_requests_events", systemHook.getMergeRequestsEvents())
.withParam("repository_update_events", systemHook.getRepositoryUpdateEvents())
.withParam("enable_ssl_verification", systemHook.getEnableSslVerification());
Response response = post(Response.Status.CREATED, formData, "hooks"); Response response = post(Response.Status.CREATED, formData, "hooks");
return (response.readEntity(SystemHook.class)); return (response.readEntity(SystemHook.class));
} }
......
...@@ -17,6 +17,7 @@ import org.gitlab4j.api.models.Email; ...@@ -17,6 +17,7 @@ import org.gitlab4j.api.models.Email;
import org.gitlab4j.api.models.GpgKey; import org.gitlab4j.api.models.GpgKey;
import org.gitlab4j.api.models.ImpersonationToken; import org.gitlab4j.api.models.ImpersonationToken;
import org.gitlab4j.api.models.ImpersonationToken.Scope; import org.gitlab4j.api.models.ImpersonationToken.Scope;
import org.gitlab4j.api.models.Membership;
import org.gitlab4j.api.models.SshKey; import org.gitlab4j.api.models.SshKey;
import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.User;
import org.gitlab4j.api.utils.EmailChecker; import org.gitlab4j.api.utils.EmailChecker;
...@@ -512,6 +513,7 @@ public class UserApi extends AbstractApi { ...@@ -512,6 +513,7 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in version 5.0, replaced by {@link #createUser(User, CharSequence, boolean)} * @deprecated Will be removed in version 5.0, replaced by {@link #createUser(User, CharSequence, boolean)}
*/ */
@Deprecated
public User createUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException { public User createUser(User user, CharSequence password, Integer projectsLimit) throws GitLabApiException {
Form formData = userToForm(user, projectsLimit, password, null, true); Form formData = userToForm(user, projectsLimit, password, null, true);
Response response = post(Response.Status.CREATED, formData, "users"); Response response = post(Response.Status.CREATED, formData, "users");
...@@ -1293,4 +1295,20 @@ public class UserApi extends AbstractApi { ...@@ -1293,4 +1295,20 @@ public class UserApi extends AbstractApi {
public void deleteGpgKey(final Integer userId, final Integer keyId) throws GitLabApiException { public void deleteGpgKey(final Integer userId, final Integer keyId) throws GitLabApiException {
delete(Response.Status.NO_CONTENT, null, "users", userId, "gpg_keys", keyId); delete(Response.Status.NO_CONTENT, null, "users", userId, "gpg_keys", keyId);
} }
/**
* Lists all projects and groups a user is a member of. (admin only)
*
* <pre><code>GitLab Endpoint: GET /users/:id/memberships</code></pre>
*
* @param userId the ID of the user to get the memberships for
* @return the list of memberships of the given user
* @throws GitLabApiException if any exception occurs
* @since GitLab 12.8
*/
public List<Membership> getMemberships(Integer userId) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm();
Response response = get(Response.Status.OK, formData.asMap(), "users", userId, "memberships");
return (response.readEntity(new GenericType<List<Membership>>() {}));
}
} }
...@@ -11,6 +11,9 @@ public class Branch { ...@@ -11,6 +11,9 @@ public class Branch {
private Boolean merged; private Boolean merged;
private String name; private String name;
private Boolean isProtected; private Boolean isProtected;
private Boolean isDefault;
private Boolean canPush;
private String webUrl;
public Commit getCommit() { public Commit getCommit() {
return commit; return commit;
...@@ -60,6 +63,30 @@ public class Branch { ...@@ -60,6 +63,30 @@ public class Branch {
this.isProtected = isProtected; this.isProtected = isProtected;
} }
public Boolean getDefault() {
return isDefault;
}
public void setDefault(Boolean isDefault) {
this.isDefault = isDefault;
}
public Boolean getCanPush() {
return canPush;
}
public void setCanPush(Boolean canPush) {
this.canPush = canPush;
}
public String getWebUrl() {
return webUrl;
}
public void setWebUrl(String webUrl) {
this.webUrl = webUrl;
}
public static final boolean isValid(Branch branch) { public static final boolean isValid(Branch branch) {
return (branch != null && branch.getName() != null); return (branch != null && branch.getName() != null);
} }
...@@ -80,11 +107,23 @@ public class Branch { ...@@ -80,11 +107,23 @@ public class Branch {
return this; return this;
} }
/**
* Set the merged attribute
* @param merged
* @deprecated Use {@link #withMerged(Boolean)} instead
* @return Current branch instance
*/
@Deprecated
public Branch withDerged(Boolean merged) { public Branch withDerged(Boolean merged) {
this.merged = merged; this.merged = merged;
return this; return this;
} }
public Branch withMerged(Boolean merged) {
this.merged = merged;
return this;
}
public Branch withName(String name) { public Branch withName(String name) {
this.name = name; this.name = name;
return this; return this;
......
package org.gitlab4j.api.models;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.gitlab4j.api.GitLabApiForm;
import org.gitlab4j.api.utils.ISO8601;
import org.gitlab4j.api.utils.JacksonJson;
import java.util.Date;
public class ChangelogPayload {
private String version;
private String from;
private String to;
private Date date;
private String branch;
private String trailer;
private String file;
private String message;
public ChangelogPayload(String version) {
this.version = version;
}
@JsonIgnore
public GitLabApiForm getFormData() {
return new GitLabApiForm()
.withParam("version", version, true)
.withParam("from", from)
.withParam("to", to)
.withParam("date", ISO8601.dateOnly(date))
.withParam("branch", branch)
.withParam("trailer", trailer)
.withParam("file", file)
.withParam("message", message);
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
public String getTrailer() {
return trailer;
}
public void setTrailer(String trailer) {
this.trailer = trailer;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
package org.gitlab4j.api.models;
import java.util.Date;
import org.gitlab4j.api.Constants;
import org.gitlab4j.api.GitLabApiForm;
import org.gitlab4j.api.Constants.DeploymentOrderBy;
import org.gitlab4j.api.Constants.DeploymentStatus;
import org.gitlab4j.api.Constants.SortOrder;
import org.gitlab4j.api.utils.ISO8601;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class DeploymentFilter {
/**
* Return deployments ordered by either one of id, iid, created_at, updated_at or ref fields. Default is id.
*/
private DeploymentOrderBy orderBy;
/**
* Return deployments sorted in asc or desc order. Default is asc.
*/
private SortOrder sortOrder;
/**
* Return deployments updated after the specified date. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
*/
private Date finishedAfter;
/**
* Return deployments updated before the specified date. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
*/
private Date finishedBefore;
/**
* The name of the environment to filter deployments by.
*/
private String environment;
/**
* The status to filter deployments by.
*/
private DeploymentStatus status;
public DeploymentOrderBy getOrderBy() {
return orderBy;
}
public void setOrderBy(DeploymentOrderBy orderBy) {
this.orderBy = orderBy;
}
public SortOrder getSortOrder() {
return sortOrder;
}
public void setSortOrder(SortOrder sortOrder) {
this.sortOrder = sortOrder;
}
public Date getFinishedAfter() {
return finishedAfter;
}
public void setFinishedAfter(Date finishedAfter) {
this.finishedAfter = finishedAfter;
}
public Date getFinishedBefore() {
return finishedBefore;
}
public void setFinishedBefore(Date finishedBefore) {
this.finishedBefore = finishedBefore;
}
public String getEnvironment() {
return environment;
}
public void setEnvironment(String environment) {
this.environment = environment;
}
public DeploymentStatus getStatus() {
return status;
}
public void setStatus(DeploymentStatus status) {
this.status = status;
}
public DeploymentFilter withOrderBy(DeploymentOrderBy orderBy) {
this.orderBy = orderBy;
return (this);
}
public DeploymentFilter withSortOrder(SortOrder sortOrder) {
this.sortOrder = sortOrder;
return (this);
}
public DeploymentFilter withFinishedAfter(Date finishedAfter) {
this.finishedAfter = finishedAfter;
return (this);
}
public DeploymentFilter withFinishedBefore(Date finishedBefore) {
this.finishedBefore = finishedBefore;
return (this);
}
public DeploymentFilter withEnvironment(String environment) {
this.environment = environment;
return (this);
}
public DeploymentFilter withStatus(DeploymentStatus status) {
this.status = status;
return (this);
}
@JsonIgnore
public GitLabApiForm getQueryParams(int page, int perPage) {
return (getQueryParams()
.withParam(Constants.PAGE_PARAM, page)
.withParam(Constants.PER_PAGE_PARAM, perPage));
}
@JsonIgnore
public GitLabApiForm getQueryParams() {
return (new GitLabApiForm()
.withParam("order_by", orderBy)
.withParam("sort", sortOrder)
.withParam("finished_after", ISO8601.toString(finishedAfter, false))
.withParam("finished_before", ISO8601.toString(finishedBefore, false))
.withParam("environment", environment)
.withParam("status", status));
}
}
package org.gitlab4j.api.models;
import org.gitlab4j.api.utils.JacksonJson;
public class Membership {
private Integer sourceId;
private String sourceName;
private MembershipSourceType sourceType;
private AccessLevel accessLevel;
public Integer getSourceId() {
return sourceId;
}
public void setSourceId(Integer sourceId) {
this.sourceId = sourceId;
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
public MembershipSourceType getSourceType() {
return sourceType;
}
public void setSourceType(MembershipSourceType sourceType) {
this.sourceType = sourceType;
}
public AccessLevel getAccessLevel() {
return accessLevel;
}
public void setAccessLevel(AccessLevel accessLevel) {
this.accessLevel = accessLevel;
}
@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment