Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #337 by setting the client properly #345

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is artifact1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is artifact2 in the "sub folder"
11 changes: 10 additions & 1 deletion jenkins-client-it-docker/jobs/test/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
<command>echo &quot;test&quot;</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<publishers>
<hudson.tasks.ArtifactArchiver>
<artifacts>**/*.txt</artifacts>
<allowEmptyArchive>false</allowEmptyArchive>
<onlyIfSuccessful>true</onlyIfSuccessful>
<fingerprint>false</fingerprint>
<defaultExcludes>true</defaultExcludes>
<caseSensitive>true</caseSensitive>
</hudson.tasks.ArtifactArchiver>
</publishers>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why you have change the content of that file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I need a job that actually does archive some files to get a proper Artifact object in NoExecutorStartedGetJobDetailsIT#shouldCheckTheBuildCause().

<buildWrappers/>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public void beforeMethod() throws IOException {
@Test
public void shouldCheckTheBuildCause() throws IOException {
BuildWithDetails details = job.getFirstBuild().details();
assertThat(details.getArtifacts()).isNotNull();
assertThat(details.getArtifacts().size()).isEqualTo(2);
details.getArtifacts().forEach(a -> assertThat(a.getClient()).isNotNull());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason why you changed the behaviour of this integration test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is required to test that "artifact.getClient()" is properly set (i.e. not null). But I guess it might be better to have a dedicated test method instead?

List<BuildCause> causes = details.getCauses();
assertThat(causes).hasSize(1);
BuildCause buildCause = causes.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.offbytwo.jenkins.client.JenkinsHttpConnection;
import com.offbytwo.jenkins.helper.BuildConsoleStreamListener;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
Expand Down Expand Up @@ -154,6 +155,14 @@ public BuildWithDetails(BuildWithDetails details) {
this.setClient(details.getClient());
}

@Override
public void setClient(JenkinsHttpConnection client) {
super.setClient(client);
if (this.artifacts != null) {
this.artifacts.stream().forEach(a -> a.setClient(client));
}
}

public List<Artifact> getArtifacts() {
return artifacts;
}
Expand Down