Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
94db1a71
Commit
94db1a71
authored
May 17, 2019
by
Greg Messner
Browse files
Needed to support actual Job Hook event (docs at GitLab are wrong) (#357).
parent
9757a7e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/webhook/BuildCommit.java
0 → 100644
View file @
94db1a71
package
org.gitlab4j.api.webhook
;
import
java.util.Date
;
import
org.gitlab4j.api.utils.JacksonJson
;
public
class
BuildCommit
{
private
Integer
id
;
private
String
sha
;
private
String
message
;
private
String
authorName
;
private
String
authorEmail
;
private
String
authorUrl
;
private
String
status
;
private
Float
duration
;
private
Date
startedAt
;
private
Date
finishedAt
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getSha
()
{
return
sha
;
}
public
void
setSha
(
String
sha
)
{
this
.
sha
=
sha
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getAuthorName
()
{
return
authorName
;
}
public
void
setAuthorName
(
String
authorName
)
{
this
.
authorName
=
authorName
;
}
public
String
getAuthorEmail
()
{
return
authorEmail
;
}
public
void
setAuthorEmail
(
String
authorEmail
)
{
this
.
authorEmail
=
authorEmail
;
}
public
String
getAuthorUrl
()
{
return
authorUrl
;
}
public
void
setAuthorUrl
(
String
authorUrl
)
{
this
.
authorUrl
=
authorUrl
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
Float
getDuration
()
{
return
duration
;
}
public
void
setDuration
(
Float
duration
)
{
this
.
duration
=
duration
;
}
public
Date
getStartedAt
()
{
return
startedAt
;
}
public
void
setStartedAt
(
Date
startedAt
)
{
this
.
startedAt
=
startedAt
;
}
public
Date
getFinishedAt
()
{
return
finishedAt
;
}
public
void
setFinishedAt
(
Date
finishedAt
)
{
this
.
finishedAt
=
finishedAt
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
\ No newline at end of file
src/main/java/org/gitlab4j/api/webhook/BuildEvent.java
0 → 100644
View file @
94db1a71
package
org.gitlab4j.api.webhook
;
import
java.util.Date
;
import
org.gitlab4j.api.models.User
;
import
org.gitlab4j.api.utils.JacksonJson
;
/**
* The documentation at: <a href="https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#job-events">
* Job Events</a> is incorrect, this class represents the actual content of the Job Hook event.
*/
public
class
BuildEvent
extends
AbstractEvent
{
public
static
final
String
JOB_HOOK_X_GITLAB_EVENT
=
"Job Hook"
;
public
static
final
String
OBJECT_KIND
=
"build"
;
private
String
ref
;
private
Boolean
tag
;
private
String
beforeSha
;
private
String
sha
;
private
Integer
buildId
;
private
String
buildName
;
private
String
buildStage
;
private
String
buildStatus
;
private
Date
buildStarted_at
;
private
Date
buildFinished_at
;
private
Float
buildDuration
;
private
Boolean
buildAllowFailure
;
private
String
buildFailureReason
;
private
Integer
projectId
;
private
String
projectName
;
private
User
user
;
private
BuildCommit
commit
;
private
EventRepository
repository
;
public
String
getObjectKind
()
{
return
(
OBJECT_KIND
);
}
public
void
setObjectKind
(
String
objectKind
)
{
if
(!
OBJECT_KIND
.
equals
(
objectKind
))
throw
new
RuntimeException
(
"Invalid object_kind ("
+
objectKind
+
"), must be '"
+
OBJECT_KIND
+
"'"
);
}
public
String
getRef
()
{
return
ref
;
}
public
void
setRef
(
String
ref
)
{
this
.
ref
=
ref
;
}
public
Boolean
getTag
()
{
return
tag
;
}
public
void
setTag
(
Boolean
tag
)
{
this
.
tag
=
tag
;
}
public
String
getBeforeSha
()
{
return
beforeSha
;
}
public
void
setBeforeSha
(
String
beforeSha
)
{
this
.
beforeSha
=
beforeSha
;
}
public
String
getSha
()
{
return
sha
;
}
public
void
setSha
(
String
sha
)
{
this
.
sha
=
sha
;
}
public
Integer
getBuildId
()
{
return
buildId
;
}
public
void
setBuildId
(
Integer
buildId
)
{
this
.
buildId
=
buildId
;
}
public
String
getBuildName
()
{
return
buildName
;
}
public
void
setBuildName
(
String
buildName
)
{
this
.
buildName
=
buildName
;
}
public
String
getBuildStage
()
{
return
buildStage
;
}
public
void
setBuildStage
(
String
buildStage
)
{
this
.
buildStage
=
buildStage
;
}
public
String
getBuildStatus
()
{
return
buildStatus
;
}
public
void
setBuildStatus
(
String
buildStatus
)
{
this
.
buildStatus
=
buildStatus
;
}
public
Date
getBuildStarted_at
()
{
return
buildStarted_at
;
}
public
void
setBuildStarted_at
(
Date
buildStarted_at
)
{
this
.
buildStarted_at
=
buildStarted_at
;
}
public
Date
getBuildFinished_at
()
{
return
buildFinished_at
;
}
public
void
setBuildFinished_at
(
Date
buildFinished_at
)
{
this
.
buildFinished_at
=
buildFinished_at
;
}
public
Float
getBuildDuration
()
{
return
buildDuration
;
}
public
void
setBuildDuration
(
Float
buildDuration
)
{
this
.
buildDuration
=
buildDuration
;
}
public
Boolean
getBuildAllowFailure
()
{
return
buildAllowFailure
;
}
public
void
setBuildAllowFailure
(
Boolean
buildAllowFailure
)
{
this
.
buildAllowFailure
=
buildAllowFailure
;
}
public
String
getBuildFailureReason
()
{
return
buildFailureReason
;
}
public
void
setBuildFailureReason
(
String
buildFailureReason
)
{
this
.
buildFailureReason
=
buildFailureReason
;
}
public
Integer
getProjectId
()
{
return
projectId
;
}
public
void
setProjectId
(
Integer
projectId
)
{
this
.
projectId
=
projectId
;
}
public
String
getProjectName
()
{
return
projectName
;
}
public
void
setProjectName
(
String
projectName
)
{
this
.
projectName
=
projectName
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
BuildCommit
getCommit
()
{
return
commit
;
}
public
void
setCommit
(
BuildCommit
commit
)
{
this
.
commit
=
commit
;
}
public
EventRepository
getRepository
()
{
return
repository
;
}
public
void
setRepository
(
EventRepository
repository
)
{
this
.
repository
=
repository
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
src/test/resources/org/gitlab4j/api/build-event.json
0 → 100644
View file @
94db1a71
{
"object_kind"
:
"build"
,
"ref"
:
"master"
,
"tag"
:
false
,
"before_sha"
:
"8a49a94f1a7cd64985074cb11b1a42a7ab2d9b46"
,
"sha"
:
"a890bee24574603c522c756b9346649fbec4c812"
,
"build_id"
:
214655258
,
"build_name"
:
"build1"
,
"build_stage"
:
"build"
,
"build_status"
:
"running"
,
"build_started_at"
:
"2019-05-17T18:09:21Z"
,
"build_duration"
:
0.05880817
,
"build_allow_failure"
:
false
,
"build_failure_reason"
:
"unknown_failure"
,
"project_id"
:
3115610
,
"project_name"
:
"GitLab4J / test-project"
,
"user"
:
{
"id"
:
20493
,
"name"
:
"GitLab4J Tester"
,
"email"
:
"gitlab4j@gitlab4j.org"
},
"commit"
:
{
"id"
:
61897408
,
"sha"
:
"a890bee24574603c522c756b9346649fbec4c812"
,
"message"
:
"Add new file"
,
"author_name"
:
"GitLab4J Tester"
,
"author_email"
:
"gitlab4j@gitlab4j.org"
,
"author_url"
:
"https://gitlab.com/gitlab4j"
,
"status"
:
"pending"
},
"repository"
:
{
"name"
:
"test-project"
,
"url"
:
"git@gitlab.com:gitlab4j/test-project.git"
,
"description"
:
"This is a test project to be used for testing the GitLab4J-API"
,
"homepage"
:
"https://gitlab.com/gitlab4j/test-project"
,
"git_http_url"
:
"https://gitlab.com/gitlab4j/test-project.git"
,
"git_ssh_url"
:
"git@gitlab.com:gitlab4j/test-project.git"
,
"visibility_level"
:
20
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment