Skip to content

Commit

Permalink
Fixed a possible NPE that can occur when properties are not turned on
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed May 30, 2016
1 parent 194b04d commit 2753448
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -42,9 +42,10 @@ public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListene

String jobName = build.getParent().getDisplayName();
HashMap<String,String> tags = new HashMap<String,String>();
DatadogJobProperty prop = DatadogUtilities.retrieveProperty(build);
// Process only if job is NOT in blacklist
if ( DatadogUtilities.isJobTracked(jobName)
&& DatadogUtilities.retrieveProperty(build).isEmitOnCheckout() ) {
&& prop != null && prop.isEmitOnCheckout() ) {
logger.fine("Checkout! in onCheckout()");

// Grab environment variables
Expand Down
Expand Up @@ -14,6 +14,7 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import jenkins.model.Jenkins;
import net.sf.json.JSONArray;
Expand Down Expand Up @@ -138,6 +139,7 @@ public static HashMap<String,String> parseTagList(Run run, TaskListener listener
* @param r - Current build.
* @return - The configured {@link DatadogJobProperty}. Null if not there
*/
@CheckForNull
public static DatadogJobProperty retrieveProperty(Run r) {
DatadogJobProperty property = (DatadogJobProperty)r.getParent()
.getProperty(DatadogJobProperty.class);
Expand Down

0 comments on commit 2753448

Please sign in to comment.