Skip to content
Permalink
Browse files

Merge pull request #5 from armfergom/JENKINS-27391

[JENKINS-27391] Properly display "Secret text" credentials name
  • Loading branch information...
jglick committed May 19, 2016
2 parents 3f3c7fd + c738192 commit 0f11129720679273cc69a09f17121e449b1f828d
@@ -29,6 +29,9 @@
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import hudson.Util;
import hudson.util.Secret;

import java.util.UUID;

import javax.annotation.Nonnull;

/**
@@ -47,9 +50,24 @@

@Override public String getName(StringCredentials c) {
String description = Util.fixEmptyAndTrim(c.getDescription());
return Messages.StringCredentials_some_text() + (description != null ? " (" + description + ")" : "");
String ID = c.getId();
return description != null ? description : (!isUUID(ID) ? ID : Messages.StringCredentials_string_credentials());
}

/**
* Checks whether an ID has UUID format
*
* @param ID the ID to check
* @return true if the ID has UUID format. False otherwise.
*/
private static boolean isUUID(String ID) {
try {
UUID.fromString(ID);
return true;
} catch (IllegalArgumentException ex) {
return false;
}
}
}

}
@@ -1 +1 @@
StringCredentials.some_text=some text
StringCredentials.string_credentials=Secret text

0 comments on commit 0f11129

Please sign in to comment.
You can’t perform that action at this time.