Skip to content

Commit

Permalink
Merge pull request #70 from shinstudio/master
Browse files Browse the repository at this point in the history
[JENKINS-31356] Manual condition and re-execute promotion bug.
  • Loading branch information
oleg-nenashev committed Nov 21, 2015
2 parents e62fc4b + 62914ac commit 069d9fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/main/java/hudson/plugins/promoted_builds/Status.java
Expand Up @@ -312,16 +312,20 @@ public boolean isManuallyApproved(){
* Schedules a new build.
*/
public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
if(!getTarget().hasPermission(Promotion.PROMOTE))
return;

ManualCondition manualCondition = (ManualCondition) getProcess().getPromotionCondition(ManualCondition.class.getName());

if(!getTarget().hasPermission(Promotion.PROMOTE)) {
if (manualCondition == null || (!manualCondition.getUsersAsSet().isEmpty() && !manualCondition.isInUsersList()
&& !manualCondition.isInGroupList()))
return;
}

JSONObject formData = req.getSubmittedForm();

List<ParameterValue> paramValues=null;
if (formData!=null){
paramValues = new ArrayList<ParameterValue>();
ManualCondition manualCondition=(ManualCondition) getProcess().getPromotionCondition(ManualCondition.class.getName());
if (manualCondition!=null){
List<ParameterDefinition> parameterDefinitions=manualCondition.getParameterDefinitions();
if (parameterDefinitions != null && !parameterDefinitions.isEmpty()) {
Expand Down
Expand Up @@ -105,6 +105,7 @@ public PromotionBadge isMet(PromotionProcess promotionProcess, AbstractBuild<?,?
return null;
}


/**
* Verifies that the currently logged in user (or anonymous) has permission
* to approve the promotion and that the promotion has not already been
Expand All @@ -126,10 +127,12 @@ public boolean canApprove(PromotionProcess promotionProcess, AbstractBuild<?,?>
return true;
}

//TODO: updated the access level to public for reuse in another class
/*
* Check if user is listed in user list as a specific user
* @since 2.24
*/
private boolean isInUsersList() {
public boolean isInUsersList() {
// Current user must be in users list or users list is empty
Set<String> usersSet = getUsersAsSet();
return usersSet.contains(Hudson.getAuthentication().getName());
Expand All @@ -138,7 +141,7 @@ private boolean isInUsersList() {
/*
* Check if user is a member of a groups as listed in the user / group field
*/
private boolean isInGroupList() {
public boolean isInGroupList() {
Set<String> groups = getUsersAsSet();
GrantedAuthority[] authorities = Hudson.getAuthentication().getAuthorities();
for (GrantedAuthority authority : authorities) {
Expand Down

0 comments on commit 069d9fd

Please sign in to comment.