Skip to content
Permalink
Browse files
Fix to persist Shelve project property whenever the job is updated
this fix would resolve JENKINS-10544
  • Loading branch information
maselvaraj authored and maselvaraj committed Mar 20, 2014
1 parent 2df406a commit ffecd58cef0007b9ac495ba7cdc850ae11a91eb6
@@ -31,13 +31,14 @@ public void onLoaded()
@Override
public void onCreated( Item item )
{
if ( item instanceof AbstractProject )
{
AbstractProject project = (AbstractProject) item;
addShelveProjectProperty( project );
}
addShelveProjectPropertyIfAbstractProject(item);
}

@Override
public void onUpdated(Item item) {
addShelveProjectPropertyIfAbstractProject(item);
}

private void addShelveProjectProperty( AbstractProject<?, ?> project )
{
try
@@ -52,4 +53,11 @@ private void addShelveProjectProperty( AbstractProject<?, ?> project )
LOGGER.log( Level.SEVERE, "Failed to persist " + project, e );
}
}

private void addShelveProjectPropertyIfAbstractProject(Item item) {
if (item instanceof AbstractProject) {
AbstractProject project = (AbstractProject) item;
addShelveProjectProperty(project);
}
}
}
@@ -84,4 +84,16 @@ public void testOnCreate_shouldAddShelveProjectActionForNewProjects()
assertEquals( "Project should have had a ShelveProjectAction added.", 1,
freeStyleProject.getActions( ShelveProjectAction.class ).size() );
}

public void testOnCreate_shouldAddShelveProjectActionForUpdatedProjects()
throws IOException
{
FreeStyleProject freeStyleProject = createFreeStyleProject( "Goofy Project" );

itemListener.onUpdated( freeStyleProject );

assertEquals( "Project should have been added just once.", 1, freeStyleProject.getActions().size() );
assertEquals( "Project should have had a ShelveProjectAction added.", 1,
freeStyleProject.getActions( ShelveProjectAction.class ).size() );
}
}

0 comments on commit ffecd58

Please sign in to comment.