-
Notifications
You must be signed in to change notification settings - Fork 9
AGDIGGER-59 trigger jenkins job #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # EditorConfig is awesome: http://EditorConfig.org | ||
|
|
||
| # top-most EditorConfig file | ||
| root = true | ||
|
|
||
| # Unix-style newlines with a newline ending every file | ||
| [*] | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| charset = utf-8 | ||
| indent_style = space | ||
| indent_size = 2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package com.redhat.digkins.model; | ||
|
|
||
| /** | ||
| * Represents the status of a build. | ||
| * <p> | ||
| * The field {@link #buildNumber} will only be set if the | ||
| * {@link #state} is {@link State#BUILDING}. | ||
| **/ | ||
| public class BuildStatus { | ||
|
|
||
| public enum State { | ||
| /** | ||
| * Build is out of the queue and it is currently being executed. | ||
| */ | ||
| BUILDING, | ||
|
|
||
| /** | ||
| * The max time to wait for the build get executed has passed. | ||
| * This state doesn't have to mean build is stuck or etc. | ||
| * It just means, the max waiting time has passed on the client side. | ||
| */ | ||
| TIMED_OUT, | ||
|
|
||
| /** | ||
| * The build is cancelled in Jenkins before it started being executed. | ||
| */ | ||
| CANCELLED_IN_QUEUE, | ||
|
|
||
| /** | ||
| * The build is stuck on Jenkins queue. | ||
| */ | ||
| STUCK_IN_QUEUE | ||
| } | ||
|
|
||
| private final State state; | ||
| private final int buildNumber; | ||
|
|
||
| public BuildStatus(State state, int buildNumber) { | ||
| this.state = state; | ||
| this.buildNumber = buildNumber; | ||
| } | ||
|
|
||
| /** | ||
| * @return state of the build | ||
| */ | ||
| public State getState() { | ||
| return state; | ||
| } | ||
|
|
||
| /** | ||
| * This should only be valid if the | ||
| * {@link #state} is {@link State#BUILDING}. | ||
| * | ||
| * @return the build number assigned by Jenkins | ||
| */ | ||
| public int getBuildNumber() { | ||
| return buildNumber; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "BuildStatus{" + | ||
| "state=" + state + | ||
| ", buildNumber=" + buildNumber + | ||
| '}'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,23 @@ | ||
| package com.redhat.digkins.services; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's do the package change in a SEPARATE PR
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
|
|
||
| import com.offbytwo.jenkins.JenkinsServer; | ||
| import org.apache.commons.io.FileUtils; | ||
| import org.jtwig.JtwigModel; | ||
| import org.jtwig.JtwigTemplate; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Create digger job on jenkins platform | ||
| */ | ||
| public class CreateJobService { | ||
|
|
||
| private JenkinsServer jenkins; | ||
| private final static String GIT_REPO_URL = "GIT_REPO_URL"; | ||
| private final static String GIT_REPO_BRANCH = "GIT_REPO_BRANCH"; | ||
|
|
||
| private final static String GIT_REPO_URL = "GIT_REPO_URL", GIT_REPO_BRANCH = "GIT_REPO_BRANCH"; | ||
| private JenkinsServer jenkins; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be |
||
|
|
||
| /** | ||
| * @param jenkins - jenkins api instance | ||
| * @param jenkins jenkins api instance | ||
| */ | ||
| public CreateJobService(JenkinsServer jenkins) { | ||
| this.jenkins = jenkins; | ||
|
|
@@ -27,9 +26,9 @@ public CreateJobService(JenkinsServer jenkins) { | |
| /** | ||
| * Create new digger job on jenkins platform | ||
| * | ||
| * @param name - job name that can be used later to reference job | ||
| * @param gitRepo - git repository url (full git repository url. e.g git@github.com:digger/helloworld.git | ||
| * @param gitBranch - git repository branch (default branch used to checkout source code) | ||
| * @param name job name that can be used later to reference job | ||
| * @param gitRepo git repository url (full git repository url. e.g git@github.com:digger/helloworld.git | ||
| * @param gitBranch git repository branch (default branch used to checkout source code) | ||
| */ | ||
| public void create(String name, String gitRepo, String gitBranch) throws IOException { | ||
| JtwigTemplate template = JtwigTemplate.classpathTemplate("templates/job.xml"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strongly recommend to extract hardcoded strings into a constant field, this way it can be found, checked and modified easier when needed. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do they have a CI running somewhere, where we can suck down the dependency ?
Not a blocker - just asking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matzew good point!
I looked now, but couldn't find anything. I checked the pom.xml files in the source code to see some repository reference. There is one, but that's not the snapshot repository.
No mention of CI.
@khmarbaise Where can we suck Jenkins-Java-client SNAPSHOT? Unfortunately, I haven't still got the approval to post to mailing list (https://groups.google.com/d/forum/java-client-api).
As a quick introduction: we are building a mobile application build farm on top of Jenkins 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asked in mailing list: https://groups.google.com/forum/#!topic/java-client-api/boD3H2KCdFg