Source Code Management Servers

This chapter is managed on source code management servers.

Get all scm servers

A GET to /scm-servers returns all the source code management servers.

HTTP request

GET /api/rest/latest/scm-servers HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

sort

which attributes of the returned entities should be sorted on (optional)

fields

which fields of the elements should be returned (optional)

type

which type of the element should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1125

{
  "_embedded" : {
    "scm-servers" : [ {
      "_type" : "scm-server",
      "id" : 1,
      "name" : "server1",
      "url" : "https://github.com/",
      "kind" : "git",
      "committer_mail" : "henix@git.fr",
      "authentication_policy" : "USER",
      "authentication_protocol" : "BASIC_AUTH",
      "repositories" : [ ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/scm-servers/1"
        }
      }
    }, {
      "_type" : "scm-server",
      "id" : 2,
      "name" : "server2",
      "url" : "https://bitbucket.org/",
      "kind" : "git",
      "committer_mail" : "henix@git.fr",
      "authentication_policy" : "USER",
      "authentication_protocol" : "BASIC_AUTH",
      "repositories" : [ ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/scm-servers/2"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers?page=0&size=20"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}

Response fields

Path Type Description

_embedded.scm-servers

Array

the list of elements for that page

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)

Get scm server

A GET to /scm-servers/{id} returns the source code management server with the given id.

Path parameters

Table 1. /api/rest/latest/scm-servers/{id}
Parameter Description

id

the id of the source code management server

HTTP request

GET /api/rest/latest/scm-servers/1 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 692

{
  "_type" : "scm-server",
  "id" : 1,
  "name" : "server1",
  "url" : "https://github.com/",
  "kind" : "git",
  "committer_mail" : "henix@git.fr",
  "authentication_policy" : "USER",
  "authentication_protocol" : "BASIC_AUTH",
  "repositories" : [ {
    "_type" : "scm-repository",
    "id" : 9,
    "name" : "GherkinTestCase",
    "repository_path" : "home/Git1",
    "working_folder_path" : "resources/features",
    "working_branch" : "master",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/scm-repositories/9"
      }
    }
  } ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/1"
    }
  }
}

Response fields

Path Type Description

_type

String

the type of the entity

id

Number

the id of the source code management server

name

String

the name of the source code management server

url

String

the url of the source code management server

kind

String

the kind of the source code management server

committer_mail

String

the committer mail used for the source code management server

authentication_policy

String

the authentication policy of the source code management server

authentication_protocol

String

the authentication protocol of the source code management server

repositories

Array

the repositories of this source code management server

_links

Object

related links

Relation Description

self

link to this source code management server

Create scm server

A POST to /scm-servers creates a new source code management server.

HTTP request

POST /api/rest/latest/scm-servers HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 118
Host: localhost:8080

{
  "name" : "New scmServer",
  "url" : "https://github.com/",
  "kind" : "git",
  "committer_mail" : "henix@git.fr"
}

Request fields

Path Type Description

name

String

the name of the source code management server (mandatory)

url

String

the url of the source code management server (mandatory)

kind

String

the kind of the source code management server (mandatory)

committer_mail

String

the committer mail used for the source code management server

Request parameters

Parameter Description

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 698

{
  "_type" : "scm-server",
  "id" : 1,
  "name" : "New scmServer",
  "url" : "https://github.com/",
  "kind" : "git",
  "committer_mail" : "henix@git.fr",
  "authentication_policy" : "USER",
  "authentication_protocol" : "BASIC_AUTH",
  "repositories" : [ {
    "_type" : "scm-repository",
    "id" : 9,
    "name" : "GherkinTestCase",
    "repository_path" : "home/Git1",
    "working_folder_path" : "resources/features",
    "working_branch" : "master",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/scm-repositories/9"
      }
    }
  } ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/1"
    }
  }
}

Response fields

Path Type Description

_type

String

the type of the entity

id

Number

the id of the source code management server

name

String

the name of the source code management server

url

String

the url of the source code management server

kind

String

the kind of the source code management server

committer_mail

String

the committer mail used for the source code management server

authentication_policy

String

the authentication policy of the source code management server

authentication_protocol

String

the authentication protocol of the source code management server

repositories

Array

the repositories of this source code management server

_links

Object

related links

Relation Description

self

link to this source code management server

Modify scm server

A PATCH to /scm-servers/{id} modifies the source code management server with the given id.

Path parameters

Table 1. /api/rest/latest/scm-servers/{id}
Parameter Description

id

the id of the source code management server

HTTP request

PATCH /api/rest/latest/scm-servers/2 HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 106
Host: localhost:8080

{
  "name" : "update scmServer",
  "url" : "https://bitbucket.org/",
  "committer_mail" : "git@henix.fr"
}

Request fields

Path Type Description

name

String

the name of the source code management server

url

String

the url of the source code management server

committer_mail

String

the committer mail used for the source code management server

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 376

{
  "_type" : "scm-server",
  "id" : 2,
  "name" : "update scmServer",
  "url" : "https://bitbucket.org/",
  "kind" : "git",
  "committer_mail" : "git@henix.fr",
  "authentication_policy" : "USER",
  "authentication_protocol" : "BASIC_AUTH",
  "repositories" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/2"
    }
  }
}

Response fields

Path Type Description

_type

String

the type of the entity

id

Number

the id of the source code management server

name

String

the name of the source code management server

url

String

the url of the source code management server

kind

String

the kind of the source code management server

committer_mail

String

the committer mail used for the source code management server

authentication_policy

String

the authentication policy of the source code management server

authentication_protocol

String

the authentication protocol of the source code management server

repositories

Array

the repositories of this source code management server

_links

Object

related links

Relation Description

self

link to this source code management server

Delete scm server

A DELETE to /scm-servers/{ids} deletes one or several source code management servers with the given id(s).

Path parameters

Table 1. /api/rest/latest/scm-servers/{ids}
Parameter Description

ids

the list of ids of the source code management servers

HTTP request

DELETE /api/rest/latest/scm-servers/11,12 HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080

HTTP response

HTTP/1.1 204 No Content

Get all scm repositories from the scm server

A GET to /scm-servers/{id}/scm-repositories returns all the source code management repository for the scm server.

HTTP request

GET /api/rest/latest/scm-servers/11/scm-repositories HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

sort

which attributes of the returned entities should be sorted on (optional)

fields

which fields of the elements should be returned (optional)

type

which type of the element should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1726

{
  "_embedded" : {
    "scm-repositories" : [ {
      "_type" : "scm-repository",
      "id" : 1,
      "name" : "GherkinTestCase",
      "repository_path" : "home/Git1",
      "working_folder_path" : "resources/features",
      "working_branch" : "master",
      "scm_server" : {
        "_type" : "scm-server",
        "id" : 11,
        "name" : "scmServer",
        "url" : "https://bitbucket.org/",
        "kind" : "git",
        "committer_mail" : "git@henix.fr",
        "_links" : {
          "self" : {
            "href" : "http://localhost:8080/api/rest/latest/scm-servers/11"
          }
        }
      },
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/scm-repositories/1"
        }
      }
    }, {
      "_type" : "scm-repository",
      "id" : 2,
      "name" : "StandardTestCase",
      "repository_path" : "home/Git2",
      "working_folder_path" : "resources/features",
      "working_branch" : "master",
      "scm_server" : {
        "_type" : "scm-server",
        "id" : 11,
        "name" : "scmServer",
        "url" : "https://bitbucket.org/",
        "kind" : "git",
        "committer_mail" : "git@henix.fr",
        "_links" : {
          "self" : {
            "href" : "http://localhost:8080/api/rest/latest/scm-servers/11"
          }
        }
      },
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/scm-repositories/2"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/11/scm-repositories?page=0&size=20"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}

Response fields

Path Type Description

_embedded.scm-repositories

Array

the list of elements for that page

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)

Add a scm repository to a scm server

A POST to /scm-servers/{id}/scm-repositories creates a new source code management repository for the given scm server id .

HTTP request

POST /api/rest/latest/scm-servers/9/scm-repositories HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 196
Host: localhost:8080

{
  "name" : "GherkinTestCase",
  "working_branch" : "master",
  "repository_path" : "home/Git1",
  "working_folder_path" : "resources/features",
  "params" : {
    "clone_repository" : true
  }
}

Path parameters

Table 1. /api/rest/latest/scm-servers/{id}/scm-repositories
Parameter Description

id

the id of the source code management server

Request fields

Path Type Description

name

String

the name of the source code management repository (mandatory)

repository_path

String

the repository path of the source code management repository (mandatory if cloning)

working_folder_path

String

the working folder path of the source code management repository

working_branch

String

the working branch of the source code management repository (mandatory)

params

Object

the parameters to create a new source code management repository

params.clone_repository

Boolean

whether the repository must be cloned on squash server file system

Request parameters

Parameter Description

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 618

{
  "_type" : "scm-repository",
  "id" : 1,
  "name" : "GherkinTestCase",
  "repository_path" : "home/Git1",
  "working_folder_path" : "resources/features",
  "working_branch" : "master",
  "scm_server" : {
    "_type" : "scm-server",
    "id" : 9,
    "name" : "server1",
    "url" : "https://github.com/",
    "kind" : "git",
    "committer_mail" : "henix@git.fr",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/scm-servers/9"
      }
    }
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/9/scm-repositories"
    }
  }
}

Response fields

Path Type Description

_type

String

the type of the entity

id

Number

the id of the source code management repository

name

String

the name of the source code management repository

repository_path

String

the repository path of the source code management repository

working_folder_path

String

the working folder path of the source code management repository

working_branch

String

the working branch of the source code management repository

scm_server

Object

the scm server this source code management repository belongs to

_links

Object

related links

Relation Description

self

link to this source code management repository

Get scm server credentials

A GET to /scm-servers/{id}/credentials get the credentials for the given source code management server.

HTTP request

GET /api/rest/latest/scm-servers/1/credentials HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080

Path parameters

Table 1. /api/rest/latest/scm-servers/{id}/credentials
Parameter Description

id

the id of the scm server

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 194

{
  "_type" : "basic-auth-credentials",
  "username" : "user@henix.fr",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/1/credentials"
    }
  }
}

Response fields

Path Type Description

_type

String

the type of the credentials, only basic-auth-credentials is used by scm servers

username

String

the username to authenticate this scm server

_links

Object

related links

Set scm server credentials

A POST to /scm-servers/{id}/credentials set credentials for the given source code management server.

HTTP request

POST /api/rest/latest/scm-servers/1/credentials HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 106
Host: localhost:8080

{
  "_type" : "basic-auth-credentials",
  "username" : "user@henix.fr",
  "password" : "qcrGmkQxI0J789F"
}

Path parameters

Table 1. /api/rest/latest/scm-servers/{id}/credentials
Parameter Description

id

the id of the scm server

Request fields

Path Type Description

_type

String

the type of the credentials, only basic-auth-credentials is used by scm servers

username

String

the username to authenticate this scm server

password

String

the password to authenticate this scm server

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 194

{
  "_type" : "basic-auth-credentials",
  "username" : "user@henix.fr",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/scm-servers/1/credentials"
    }
  }
}

Response fields

Path Type Description

_type

String

the type of the credentials, only basic-auth-credentials is used by scm servers

username

String

the username to authenticate this scm server

_links

Object

related links