-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add a link to Datadog to job details page #447
Draft
nikita-tkachenko-datadog
wants to merge
4
commits into
master
Choose a base branch
from
nikita-tkachenko/add-datadog-link
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
22d726b
Add a link to Datadog to job details page
nikita-tkachenko-datadog bda6571
Only add link to Datadog if CI Visibility is enabled
nikita-tkachenko-datadog 4cf30ab
Fix compilation error
nikita-tkachenko-datadog 0277c0d
Only show Datadog link if site is configured + allow configuring site…
nikita-tkachenko-datadog 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
70 changes: 70 additions & 0 deletions
70
src/main/java/org/datadog/jenkins/plugins/datadog/model/DatadogLinkAction.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,70 @@ | ||
package org.datadog.jenkins.plugins.datadog.model; | ||
|
||
import com.thoughtworks.xstream.XStream; | ||
import com.thoughtworks.xstream.converters.MarshallingContext; | ||
import com.thoughtworks.xstream.converters.UnmarshallingContext; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamReader; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; | ||
import hudson.model.Action; | ||
import org.datadog.jenkins.plugins.datadog.util.conversion.DatadogConverter; | ||
import org.datadog.jenkins.plugins.datadog.util.conversion.VersionedConverter; | ||
|
||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.datadog.jenkins.plugins.datadog.util.conversion.VersionedConverter.ignoreOldData; | ||
|
||
public class DatadogLinkAction implements Action { | ||
|
||
private final String url; | ||
|
||
public DatadogLinkAction(BuildData buildData, String siteName) { | ||
String query = String.format("ci_level:pipeline @ci.pipeline.name:\"%s\" @ci.pipeline.number:%s", buildData.getJobName(), buildData.getBuildNumber("")); | ||
String urlEncodedQuery = URLEncoder.encode(query, StandardCharsets.UTF_8); | ||
this.url = String.format("https://app.%s/ci/pipeline-executions?query=%s", siteName, urlEncodedQuery); | ||
} | ||
|
||
private DatadogLinkAction(String url) { | ||
this.url = url; | ||
} | ||
|
||
@Override | ||
public String getIconFileName() { | ||
return "/plugin/datadog/icons/dd_icon_rgb.svg"; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "View in Datadog"; | ||
} | ||
|
||
@Override | ||
public String getUrlName() { | ||
return url; | ||
} | ||
|
||
public static final class ConverterImpl extends DatadogConverter<DatadogLinkAction> { | ||
public ConverterImpl(XStream xs) { | ||
super(ignoreOldData(), new ConverterV1()); | ||
} | ||
} | ||
|
||
public static final class ConverterV1 extends VersionedConverter<DatadogLinkAction> { | ||
private static final int VERSION = 1; | ||
|
||
public ConverterV1() { | ||
super(VERSION); | ||
} | ||
|
||
@Override | ||
public void marshal(DatadogLinkAction action, HierarchicalStreamWriter writer, MarshallingContext context) { | ||
writeField("url", action.url, writer, context); | ||
} | ||
|
||
@Override | ||
public DatadogLinkAction unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { | ||
String url = readField(reader, context, String.class); | ||
return new DatadogLinkAction(url); | ||
} | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
...rg/datadog/jenkins/plugins/datadog/configuration/DatadogAgentConfiguration/help-site.html
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,4 @@ | ||
<div> | ||
Select your Datadog site. | ||
See <a target="_blank" href="https://docs.datadoghq.com/getting_started/site/">Datadog documentation</a> for more information about sites. | ||
</div> |
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.
Oops, something went wrong.
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.
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check Warning