Skip to content

Commit

Permalink
Removed the port configuration option.
Browse files Browse the repository at this point in the history
The port sometimes might appear inside the connection address, but not at the end. If we would keep separate setting for the port, then it would be not possible to configure such a case.
  • Loading branch information
krzysztof-lorenc committed Apr 25, 2019
1 parent 3d91190 commit a31a8e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
6 changes: 2 additions & 4 deletions src/Soloplan.WhatsON.Jenkins/JenkinsAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@ public class JenkinsApi : IJenkinsApi
public async Task<JenkinsJob> GetJenkinsJob(JenkinsProject subject, CancellationToken token)
{
var address = subject.GetAddress();
var port = subject.GetPort();
var projectName = subject.GetProject();

var jobRequest = $"{address.Trim('/')}:{port}/job/{projectName.Trim('/')}/api/json?tree={JenkinsJob.RequestProperties}";
var jobRequest = $"{address.Trim('/')}/job/{projectName.Trim('/')}/api/json?tree={JenkinsJob.RequestProperties}";
log.Trace("Querying job: {jobRequest}", jobRequest);
return await GetJenkinsModel<JenkinsJob>(subject, jobRequest, token);
}

public async Task<JenkinsBuild> GetJenkinsBuild(JenkinsProject subject, int buildNumber, CancellationToken token)
{
var address = subject.GetAddress();
var port = subject.GetPort();
var projectName = subject.GetProject();

var buildRequest = $"{address.Trim('/')}:{port}/job/{projectName.Trim('/')}/{buildNumber}/api/json?tree={JenkinsBuild.RequestProperties}";
var buildRequest = $"{address.Trim('/')}/job/{projectName.Trim('/')}/{buildNumber}/api/json?tree={JenkinsBuild.RequestProperties}";
log.Trace("Querying build: {jobRequest}", buildRequest);
return await GetJenkinsModel<JenkinsBuild>(subject, buildRequest, token);
}
Expand Down
32 changes: 0 additions & 32 deletions src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Soloplan.WhatsON.Jenkins
[SubjectType("Jenkins Project Status", Description = "Retrieve the current status of a Jenkins project.")]
[ConfigurationItem(ProjectName, typeof(string), Optional = false, Priority = 300)]
[ConfigurationItem(RedirectPlugin, typeof(bool), Priority = 400)] // defines use of Display URL API Plugin https://wiki.jenkins.io/display/JENKINS/Display+URL+API+Plugin
[ConfigurationItem(ServerPort, typeof(int), Priority = 200)]
public class JenkinsProject : ServerSubject
{
public const string ProjectName = "ProjectName";
Expand All @@ -27,11 +26,6 @@ public class JenkinsProject : ServerSubject
/// </summary>
public const string RedirectPlugin = "RedirectPlugin";

/// <summary>
/// The server port.
/// </summary>
public const string ServerPort = "Port";

/// <summary>
/// Logger instance used by this class.
/// </summary>
Expand All @@ -55,23 +49,6 @@ public JenkinsProject(SubjectConfiguration configuration, IJenkinsApi api)

public string Project => this.GetProject();

/// <summary>
/// Gets the port number.
/// </summary>
public int Port
{
get
{
var configItem = this.SubjectConfiguration.GetConfigurationByKey(ServerPort);
if (configItem != null)
{
return int.TryParse(configItem.Value, out var port) ? port : GetDefaultPort(this.Address);
}

return 80;
}
}

private JenkinsStatus PreviousCheckStatus { get; set; }

/// <summary>
Expand All @@ -83,15 +60,6 @@ public string GetProject()
return this.SubjectConfiguration.GetConfigurationByKey(JenkinsProject.ProjectName).Value;
}

/// <summary>
/// Gets the port.
/// </summary>
/// <returns>The port number.</returns>
public string GetPort()
{
return this.SubjectConfiguration.GetConfigurationByKey(ServerPort).Value;
}

protected override async Task ExecuteQuery(CancellationToken cancellationToken, params string[] args)
{
var job = await this.api.GetJenkinsJob(this, cancellationToken);
Expand Down

0 comments on commit a31a8e0

Please sign in to comment.