Added function for verify user presence
Change-Id: I4fd079c1c5e1c5f676ccb1df3ba8b7c067b843ee
diff --git a/src/com/mirantis/mk/JenkinsUtils.groovy b/src/com/mirantis/mk/JenkinsUtils.groovy
index 25395e6..43be87b 100644
--- a/src/com/mirantis/mk/JenkinsUtils.groovy
+++ b/src/com/mirantis/mk/JenkinsUtils.groovy
@@ -8,6 +8,25 @@
*/
/**
+ * Tests if current user belongs to given group
+ * @param groupName name of the group you want to verify user presence
+ * @return boolean result
+ */
+def currentUserInGroup(groupName){
+ def hasAccess = false
+ wrap([$class: 'BuildUser']) {
+ def authorities = Jenkins.instance.securityRealm.loadUserByUsername(BUILD_USER).getAuthorities()
+ for(int i=0;i < authorities.size();i++){
+ if(authorities[i].equals(groupName)){
+ hasAccess=true
+ break
+ }
+ }
+ }
+ return hasAccess
+}
+
+/**
* Get Jenkins job running builds
* @param jobName job name
* @return list of running builds
@@ -47,4 +66,4 @@
}
}
return result
-}
\ No newline at end of file
+}