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

[JENKINS-36305] Fix TestObject url in order to fix TestActions links #50

Merged
merged 5 commits into from
Oct 8, 2020

Conversation

Vlatombe
Copy link
Member

@ghost
Copy link

ghost commented Jun 29, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick
Copy link
Member

jglick commented Jun 29, 2016

This seems like it would be incompatible. What was the actual source of the 404? Sounds like a bug in the junit-attachments plugin, no? Here specifically.

@Vlatombe
Copy link
Member Author

yes indeed it is incompatible. junit-attachments could implement a workaround by building an absolute path at the line you pointed. But I believe the bug lies in junit-plugin, which is using a taglib expecting a different contract on #getUrl().

@Vlatombe
Copy link
Member Author

@jglick do you think it is unacceptable to break compatibility here? With the current implementation, TestActions that want to be exposed in sidebar cannot use relative urls, unlike regular Actions.

@jglick
Copy link
Member

jglick commented Jul 1, 2016

Perhaps this was not the best design choice, if junit foresaw the possibility of test actions being in the sidebar, but changing this behavior now seems too dangerous when there is a simple solution in the plugin actually affected by the bug.

@Vlatombe
Copy link
Member Author

Vlatombe commented Jul 7, 2016

I gave a shot to specifying getUrlName with the following contract in junit-attachments

If the returned string starts with '/', like '/foo', then it's assumed to be
relative to the context path of the Jenkins webapp.

But then I realised this can't work because of https://github.com/jenkinsci/junit-plugin/blob/master/src/main/java/hudson/tasks/test/TestObject.java#L442.

Bottom line: if you don't use relative path, then the action isn't bound so you can't access it.

The current PR is the only way I see to fix it.

@oleg-nenashev
Copy link
Member

@Vlatombe are you still working on it?

@Vlatombe
Copy link
Member Author

@oleg-nenashev I still stand by what I said in my last comment. IMO this PR is the only way to fix properly the link in junit-attachment, and I don't see any simple solution to fix it without affecting junit-plugin.

Vlatombe added a commit to Vlatombe/junit-attachments-plugin that referenced this pull request Sep 24, 2016
Vlatombe added a commit to Vlatombe/junit-attachments-plugin that referenced this pull request Sep 24, 2016
@oleg-nenashev
Copy link
Member

After some review 👍 from me

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Not sure I understand the compatibility implications well enough to be comfortable merging. Will leave it to @oleg-nenashev to consider.

*
* @return the url relative to {@link TestResult}.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we could deprecate the old method and introduce a replacement intended to have different behavior?

Copy link
Member Author

@Vlatombe Vlatombe Sep 30, 2020

Choose a reason for hiding this comment

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

@oleg-nenashev oleg-nenashev self-assigned this Feb 16, 2017
@oleg-nenashev
Copy link
Member

Not sure I understand the compatibility implications well enough to be comfortable merging. Will leave it to @oleg-nenashev to consider.

I should have explained my PoV regarding the compatibility more explicitly. Then I would be able to read it now and restore the context :( Will review from scratch

@oleg-nenashev oleg-nenashev removed their assignment Mar 3, 2018
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Apparently I did not. I will leave the decision about merge to the plugin maintainer (if any)

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

@Vlatombe are you still interested in this PR? or shall we close it.

src/main/java/hudson/tasks/junit/History.java Outdated Show resolved Hide resolved
@Vlatombe
Copy link
Member Author

@timja I'll check whether it still makes sense.

@Vlatombe
Copy link
Member Author

Updated.

@timja
Copy link
Member

timja commented Sep 30, 2020

I’ll take a look next week

@timja
Copy link
Member

timja commented Oct 5, 2020

I'm struggling to test this any hints?

I have a freestyle build with this:

rm *.xml
wget https://raw.githubusercontent.com/jenkinsci/junit-plugin/master/src/test/resources/hudson/tasks/junit/pipeline/junit-report-testTrends-first-2.xml

mkdir -p org.twia.vendor.VendorManagerTest
echo 'hello' > org.twia.vendor.VendorManagerTest/attachment.txt

echo "[[ATTACHMENT|${WORKSPACE}/org.twia.vendor.VendorManagerTest/attachment.txt]]"

and I've configured the publisher =/

image

the attachment isn't showing up

@Override
public String getUrl() {
return '/' + getId();
return getRun().getUrl() + getTestResultAction().getUrlName() + "/" + getId();
Copy link
Member

@jtnord jtnord Sep 30, 2020

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

not really sure how to test this =/, I tried with the tests in https://github.com/jenkinsci/cucumber-testresult-plugin and these: https://github.com/testdouble/java-cucumber-example

@jtnord
Copy link
Member

jtnord commented Oct 5, 2020

I'm struggling to test this any hints?

I have a freestyle build with this:

rm *.xml
wget https://raw.githubusercontent.com/jenkinsci/junit-plugin/master/src/test/resources/hudson/tasks/junit/pipeline/junit-report-testTrends-first-2.xml

mkdir -p org.twia.vendor.VendorManagerTest
echo 'hello' > org.twia.vendor.VendorManagerTest/attachment.txt

echo "[[ATTACHMENT|${WORKSPACE}/org.twia.vendor.VendorManagerTest/attachment.txt]]"

and I've configured the publisher =/

image

the attachment isn't showing up

normally the "output" needs to be part of the test output not the job console output (and captured by junit (in its sdr-err or std-out element IIRC))

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

reproduced the bug and verified that this PR fixes it.

I created https://github.com/timja/junit-attachments-test/blob/master/src/test/java/com/github/AppTest.java#L25 to verify it.

Checking @jtnord 's comment before merging

@timja timja merged commit d7d76b4 into jenkinsci:master Oct 8, 2020
@Vlatombe Vlatombe deleted the JENKINS-36305 branch October 8, 2020 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants