use of net.nemerosa.ontrack.extension.jenkins.client.JenkinsClient in project ontrack by nemerosa.
the class JenkinsJobDecorationExtension method getDecorations.
@Override
public List<Decoration<JenkinsJob>> getDecorations(ProjectEntity entity) {
// Gets the Jenkins Job property for this entity, if any
Property<JenkinsJobProperty> property = propertyService.getProperty(entity, JenkinsJobPropertyType.class.getName());
if (property.isEmpty()) {
return Collections.emptyList();
} else {
// Template branch? Decoration cannot be computed
if (entity instanceof Branch && ((Branch) entity).getType() == BranchType.TEMPLATE_DEFINITION) {
return Collections.emptyList();
}
// Gets a client
// FIXME getJob does not need a full HTTP client
JenkinsClient jenkinsClient = jenkinsClientFactory.getClient(property.getValue().getConfiguration());
// Gets the Jenkins job
JenkinsJob job = jenkinsClient.getJob(property.getValue().getJob());
// Gets the decoration for the job
return Collections.singletonList(getDecoration(job));
}
}
use of net.nemerosa.ontrack.extension.jenkins.client.JenkinsClient in project ontrack by nemerosa.
the class JenkinsServiceTest method before.
@Before
public void before() {
SecurityService securityService = mock(SecurityService.class);
configurationRepository = mock(ConfigurationRepository.class);
encryptionService = mock(EncryptionService.class);
JenkinsClientFactory jenkinsClientFactory = mock(JenkinsClientFactory.class);
JenkinsClient okJenkinsClient = mock(JenkinsClient.class);
when(jenkinsClientFactory.getClient(any(JenkinsConfiguration.class))).thenReturn(okJenkinsClient);
OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
jenkinsService = new JenkinsConfigurationServiceImpl(configurationRepository, securityService, encryptionService, mock(EventPostService.class), mock(EventFactory.class), jenkinsClientFactory, ontrackConfigProperties);
}
Aggregations