-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to display information about the .ci.yml/shell script that…
… was used to run the build
- Loading branch information
1 parent
3437d7b
commit e63281a
Showing
11 changed files
with
205 additions
and
9 deletions.
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
108 changes: 108 additions & 0 deletions
108
src/main/java/com/groupon/jenkins/dynamic/build/DotCiBuildInfoAction.java
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,108 @@ | ||
/* | ||
The MIT License (MIT) | ||
Copyright (c) 2016, Groupon, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
package com.groupon.jenkins.dynamic.build; | ||
|
||
import com.google.common.base.Joiner; | ||
import com.groupon.jenkins.buildtype.util.shell.ShellCommands; | ||
import hudson.model.Run; | ||
import jenkins.model.RunAction2; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import org.kohsuke.stapler.StaplerResponse; | ||
|
||
import javax.servlet.ServletException; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
public class DotCiBuildInfoAction implements RunAction2 { | ||
private List<String> commands; | ||
private String buildConfiguration; | ||
|
||
public DotCiBuildInfoAction() { | ||
this.commands = new ArrayList<>(); | ||
this.buildConfiguration = ""; | ||
} | ||
|
||
public DotCiBuildInfoAction(final ShellCommands commands) { | ||
this(); | ||
this.commands = new ArrayList<>(commands.getCommands()); | ||
|
||
} | ||
|
||
public DotCiBuildInfoAction(final String buildConfiguration) { | ||
this(); | ||
this.buildConfiguration = buildConfiguration; | ||
} | ||
|
||
public String getBuildConfiguration() { | ||
return this.buildConfiguration; | ||
} | ||
|
||
public void setBuildConfiguration(final String buildConfiguration) { | ||
this.buildConfiguration = buildConfiguration; | ||
|
||
} | ||
|
||
public String getScript() { | ||
return this.commands == null ? "" : Joiner.on("\n").join(this.commands); | ||
} | ||
|
||
public void doBuildScript(final StaplerRequest req, final StaplerResponse rsp) throws ServletException, IOException { | ||
final InputStream file = new ByteArrayInputStream(getScript().getBytes(StandardCharsets.UTF_8)); | ||
rsp.serveFile(req, file, new Date().getTime(), 0, -1L, "dotci.sh"); | ||
} | ||
|
||
@Override | ||
public void onAttached(final Run<?, ?> r) { | ||
|
||
} | ||
|
||
@Override | ||
public void onLoad(final Run<?, ?> r) { | ||
|
||
} | ||
|
||
@Override | ||
public String getIconFileName() { | ||
return "/plugin/DotCi/images/24x24/logo.png"; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "DotCi Build Info"; | ||
} | ||
|
||
@Override | ||
public String getUrlName() { | ||
return "dotCiBuildInfo"; | ||
} | ||
|
||
public void addCommands(final ShellCommands commands) { | ||
this.commands.addAll(commands.getCommands()); | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/main/resources/com/groupon/jenkins/dynamic/build/DotCiBuildInfoAction/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" | ||
xmlns:l="/lib/layout" xmlns:f="/lib/form" | ||
> | ||
<l:layout> | ||
<l:main-panel> | ||
<div class="main"> | ||
<script | ||
src="${resURL}/plugin/DotCi/js/highlight.pack.js"></script> | ||
<link rel="stylesheet" type="text/css" | ||
href="${resURL}/plugin/DotCi/css/github.css"/> | ||
|
||
<script>hljs.initHighlightingOnLoad();</script> | ||
<p> | ||
<b>.ci.yml</b> | ||
<pre> | ||
<code class="yaml">${it.buildConfiguration}</code> | ||
</pre> | ||
|
||
</p> | ||
<p> | ||
<b>Bash Script</b> | ||
<pre> | ||
<code class="bash">${it.script}</code> | ||
</pre> | ||
<p> | ||
<f:form method="post" action="buildScript" | ||
name="downloadScript"> | ||
<f:submit value="Download Script"/> | ||
</f:form> | ||
</p> | ||
</p> | ||
</div> | ||
</l:main-panel> | ||
</l:layout> | ||
</j: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
chmod -R u+w . ; find . ! -path "./deploykey_rsa.pub" ! -path "./deploykey_rsa" -delete | ||
git init | ||
git remote add origin https://github.com/suryagaddipati/DotCi.git | ||
git fetch origin master | ||
git reset --hard 12a7850061f62184459b5590b35ee4f095659004 |
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,5 @@ | ||
chmod -R u+w . ; find . ! -path "./deploykey_rsa.pub" ! -path "./deploykey_rsa" -delete | ||
git init | ||
git remote add origin https://github.com/suryagaddipati/DotCi.git | ||
git fetch origin master | ||
git reset --hard 12a7850061f62184459b5590b35ee4f095659004 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.