API: Version information
This commit is contained in:
		
							parent
							
								
									7c07c07d7a
								
							
						
					
					
						commit
						b998479c81
					
				|  | @ -30,6 +30,7 @@ v 8.13.0 (unreleased) | ||||||
|   - Cache rendered markdown in the database, rather than Redis |   - Cache rendered markdown in the database, rather than Redis | ||||||
|   - Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references |   - Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references | ||||||
|   - Simplify Mentionable concern instance methods |   - Simplify Mentionable concern instance methods | ||||||
|  |   - API: Ability to retrieve version information (Robert Schilling) | ||||||
|   - Fix permission for setting an issue's due date |   - Fix permission for setting an issue's due date | ||||||
|   - API: Multi-file commit !6096 (mahcsig) |   - API: Multi-file commit !6096 (mahcsig) | ||||||
|   - Revert "Label list shows all issues (opened or closed) with that label" |   - Revert "Label list shows all issues (opened or closed) with that label" | ||||||
|  |  | ||||||
|  | @ -46,6 +46,7 @@ following locations: | ||||||
| - [Todos](todos.md) | - [Todos](todos.md) | ||||||
| - [Users](users.md) | - [Users](users.md) | ||||||
| - [Validate CI configuration](ci/lint.md) | - [Validate CI configuration](ci/lint.md) | ||||||
|  | - [Version](version.md) | ||||||
| 
 | 
 | ||||||
| ### Internal CI API | ### Internal CI API | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | # Version API | ||||||
|  | 
 | ||||||
|  | >**Note:** This feature was introduced in GitLab 8.13 | ||||||
|  | 
 | ||||||
|  | Retrieve version information for this GitLab instance. Responds `200 OK` for | ||||||
|  | authenticated users. | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | GET /version | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ```bash | ||||||
|  | curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/version | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | Example response: | ||||||
|  | 
 | ||||||
|  | ```json | ||||||
|  | { | ||||||
|  |   "version": "8.13.0-pre", | ||||||
|  |   "revision": "4e963fe" | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  | @ -73,6 +73,7 @@ module API | ||||||
|     mount ::API::Triggers |     mount ::API::Triggers | ||||||
|     mount ::API::Users |     mount ::API::Users | ||||||
|     mount ::API::Variables |     mount ::API::Variables | ||||||
|  |     mount ::API::Version | ||||||
| 
 | 
 | ||||||
|     route :any, '*path' do |     route :any, '*path' do | ||||||
|       error!('404 Not Found', 404) |       error!('404 Not Found', 404) | ||||||
|  |  | ||||||
|  | @ -0,0 +1,12 @@ | ||||||
|  | module API | ||||||
|  |   class Version < Grape::API | ||||||
|  |     before { authenticate! } | ||||||
|  | 
 | ||||||
|  |     desc 'Get the version information of the GitLab instance.' do | ||||||
|  |       detail 'This feature was introduced in GitLab 8.13.' | ||||||
|  |     end | ||||||
|  |     get '/version' do | ||||||
|  |       { version: Gitlab::VERSION, revision: Gitlab::REVISION } | ||||||
|  |     end | ||||||
|  |   end | ||||||
|  | end | ||||||
|  | @ -0,0 +1,27 @@ | ||||||
|  | require 'spec_helper' | ||||||
|  | 
 | ||||||
|  | describe API::API, api: true do | ||||||
|  |   include ApiHelpers | ||||||
|  | 
 | ||||||
|  |   describe 'GET /version' do | ||||||
|  |     context 'when unauthenticated' do | ||||||
|  |       it 'returns authentication error' do | ||||||
|  |         get api('/version') | ||||||
|  | 
 | ||||||
|  |         expect(response).to have_http_status(401) | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|  |     context 'when authenticated' do | ||||||
|  |       let(:user) { create(:user) } | ||||||
|  | 
 | ||||||
|  |       it 'returns the version information' do | ||||||
|  |         get api('/version', user) | ||||||
|  | 
 | ||||||
|  |         expect(response).to have_http_status(200) | ||||||
|  |         expect(json_response['version']).to eq(Gitlab::VERSION) | ||||||
|  |         expect(json_response['revision']).to eq(Gitlab::REVISION) | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  |   end | ||||||
|  | end | ||||||
		Loading…
	
		Reference in New Issue