Skip to content

Commit

Permalink
[JENKINS-31356] Manual condition and re-execute promotion bug. doBuil…
Browse files Browse the repository at this point in the history
…d checked an user for only project permission level when it had to check the approver list as well
  • Loading branch information
shinstudio committed Nov 3, 2015
1 parent 4223721 commit edc921c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/main/java/hudson/plugins/promoted_builds/Status.java
Expand Up @@ -312,16 +312,21 @@ 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.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 @@ -129,7 +130,7 @@ public boolean canApprove(PromotionProcess promotionProcess, AbstractBuild<?,?>
/*
* Check if user is listed in user list as a specific user
*/
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 +139,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 edc921c

Please sign in to comment.