-
Notifications
You must be signed in to change notification settings - Fork 829
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
added embedded API Viewer #822
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3f53848
added embedded API Viewer
daspilker 64d70e4
load DSL data from classpath to fix "gradle server"
daspilker 39dfd74
use Gradle for downloading Update Center data to allow incremental bu…
daspilker 2ffe82d
specify inputs and outputs for Gulp build task to allow incremental b…
daspilker eabdf68
use constant name for latest DSL API JSON file
daspilker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/JobDslPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package javaposse.jobdsl.plugin | ||
|
||
import hudson.Plugin | ||
import javaposse.jobdsl.dsl.JobManagement | ||
import jenkins.model.Jenkins | ||
import net.sf.json.JSONObject | ||
import org.kohsuke.stapler.StaplerRequest | ||
import org.kohsuke.stapler.StaplerResponse | ||
|
||
import javax.servlet.ServletException | ||
|
||
import static hudson.model.UpdateCenter.ID_DEFAULT | ||
|
||
class JobDslPlugin extends Plugin { | ||
private JSONObject api | ||
|
||
@Override | ||
void postInitialize() throws Exception { | ||
api = JSONObject.fromObject(JobManagement.getResource('dsl.json').text) | ||
api.element('embedded', true) | ||
} | ||
|
||
@Override | ||
void doDynamic(StaplerRequest request, StaplerResponse response) throws IOException, ServletException { | ||
String path = request.restOfPath | ||
if (path == '/api-viewer') { | ||
response.sendRedirect("${request.requestURI}/index.html") | ||
} else if (path == '/api-viewer/build/data/update-center.jsonp') { | ||
JSONObject data = Jenkins.instance.updateCenter.getById(ID_DEFAULT).JSONObject | ||
response.contentType = 'application/javascript' | ||
response.writer.print("updateCenter.post(${data.toString()})") | ||
} else if (path == '/api-viewer/build/data/dsl.json') { | ||
response.contentType = 'application/json' | ||
response.writer.print(api.toString()) | ||
} else { | ||
super.doDynamic(request, response) | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/actions/ApiViewerAction.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package javaposse.jobdsl.plugin.actions | ||
|
||
import hudson.model.Action | ||
|
||
class ApiViewerAction implements Action { | ||
final String iconFileName = '/plugin/job-dsl/images/48x48/directory.png' | ||
final String displayName = 'Job DSL API Reference' | ||
final String urlName = '/plugin/job-dsl/api-viewer' | ||
} |
4 changes: 3 additions & 1 deletion
4
job-dsl-plugin/src/main/resources/javaposse/jobdsl/plugin/ExecuteDslScripts/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I had to add
here to get this to work. I was getting:
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.
Thanks for the hint. I want to get rid of the JSONP stuff. Maybe the JSONP can be processed in Gradle or Grunt to remove the padding. But that's another PR.