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

add support for ranking after #1160

Merged
merged 2 commits into from
Oct 17, 2021
Merged

add support for ranking after #1160

merged 2 commits into from
Oct 17, 2021

Conversation

durka
Copy link
Contributor

@durka durka commented Sep 25, 2021

Adds a parameter to JIRA.rank to support ranking an issue after another one, as well as before.

The reason this is necessary is if you have a list of issues, to move one to the end, the "rank before" operation is not sufficient as there is no next issue.

Since the function is kind of long, to avoid duplication I went with adding a parameter. The current usage is unaffected:

# rank A before B
jira.rank('A', 'B')

Although it might be clearer like this:

# rank A before B
jira.rank('A', next_issue='B')

To contrast with the new syntax:

# rank A after B
jira.rank('A', prev_issue='B')

Note that passing neither or both optional parameters will throw an exception.

I added a test, but unfortunately ranking does not seem to work in the docker instance so I marked it broken. Did I miss something?

@durka
Copy link
Contributor Author

durka commented Sep 25, 2021

Would ranking work in the test if I create an epic first? Unfortunately can't seem to test locally, the tests always say "Connection aborted" even though it was working five minutes ago.

@durka
Copy link
Contributor Author

durka commented Sep 27, 2021

OK, was finally able to test on a different computer. Adding the issues to an epic doesn't help, so I guess there is just no ranking in the test instance?

@adehad adehad self-requested a review September 28, 2021 07:43
@adehad
Copy link
Contributor

adehad commented Sep 28, 2021

Any chance you are using Jira Cloud actually?
I can find the reference for rankng issues in Jira Cloud: https://developer.atlassian.com/cloud/jira/software/rest/api-group-issue/#api-agile-1-0-issue-rank-put

But nothing for Jira Server https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/) which we currently se for the test instance (there is some work to start testing on Jira Cloud, but it is still in progress, e.g. #1107 )

@durka
Copy link
Contributor Author

durka commented Sep 28, 2021

Yes I personally use Jira Cloud where ranking does work! So that's where I developed this, I haven't tested the very latest version that I pushed here but I can just do some more hand-testing if that is the best way forward.

@adehad
Copy link
Contributor

adehad commented Sep 29, 2021

Gotcha, we do have a Jira Cloud instance we can test on, so I'll try and test on that for you. For now what you've done with the @broken_test is fine. Once I'm confident it works on Jira Cloud I'll be happy to merge!

@durka
Copy link
Contributor Author

durka commented Oct 9, 2021

Ping did you ever get a chance to test this?

@adehad
Copy link
Contributor

adehad commented Oct 11, 2021

Sorry I haven't got the chance yet, might get an opportunity this upcoming weekend. Thanks

Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

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

Hi @durka !

I've been able to test this now, and actually have found it to work on both Jira Server and Cloud, although there are a handful of problems I had to navigate.

Here is the endpoint for Jira Server, confirming it does exist:
https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/issue-rankIssues

I can see that the rank() function does tries to account for different endpoint parameters in rank%sIssue vs rank%sKey (legacy Greenhopper API), but it looks like the Server endpoint parameters are now the same as the Cloud ones, so this difference is no longer necessary. We can also see from both the docs for these endpoints that they use the agile rather than legacy greenhopper url.

I've made a PR for updating the default api endpoint here: #1186 .

If you can rebase this branch to the branch used in #1186 I'm pretty confident the tests will pass without needing @broken_test

jira/client.py Outdated Show resolved Hide resolved
jira/client.py Show resolved Hide resolved
tests/resources/test_issue.py Outdated Show resolved Hide resolved
@durka
Copy link
Contributor Author

durka commented Oct 16, 2021

Side note: do you have trouble running the test server instance? For me, it fails almost every time. It only works if I add --network=host.

I will try to open an issue about this, although the bug template is cumbersome with a lot of questions I can't answer.

$ docker run --rm -dit -p 2990:2990 --name jira addono/jira-software-standalone
252e7033b059ba511d8aed16a5d6feb34f46a370a51adbd9e6bb0eecc4109c59
$ docker logs -f jira
[INFO] Project POM found
[INFO] Resolving plugin info, may take a while on the first run.
[INFO] Scanning for projects...
[INFO] Downloading from atlassian-public: https://maven.atlassian.com/repository/public/com/atlassian/maven/plugins/jira-maven-plugin/8.0.2/jira-maven-plugin-8.0.2.pom
[INFO] Downloading from atlassian-plugin-sdk: file:///usr/share/atlassian-plugin-sdk-8.2.8/repository/com/atlassian/maven/plugins/jira-maven-plugin/8.0.2/jira-maven-plugin-8.0.2.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/atlassian/maven/plugins/jira-maven-plugin/8.0.2/jira-maven-plugin-8.0.2.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin com.atlassian.maven.plugins:jira-maven-plugin:8.0.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.atlassian.maven.plugins:jira-maven-plugin:jar:8.0.2 @ 
[ERROR] Unknown packaging: atlassian-plugin @ line 19, column 16
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project mygroup:myartifact:1.0.0-SNAPSHOT (/pom.xml) has 2 errors
[ERROR]     Unresolveable build extension: Plugin com.atlassian.maven.plugins:jira-maven-plugin:8.0.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.atlassian.maven.plugins:jira-maven-plugin:jar:8.0.2: Could not transfer artifact com.atlassian.maven.plugins:jira-maven-plugin:pom:8.0.2 from/to atlassian-public (https://maven.atlassian.com/repository/public): maven.atlassian.com: Name or service not known: Unknown host maven.atlassian.com: Name or service not known -> [Help 2]
[ERROR]     Unknown packaging: atlassian-plugin @ line 19, column 16
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

These URLs it's complaining about open fine in a browser so I don't know why docker is failing.

@durka
Copy link
Contributor Author

durka commented Oct 16, 2021

OK, looks good now, works on both server and cloud for me. Now waiting for your other MR to be merged.

@adehad adehad added the feature label Oct 16, 2021
@adehad
Copy link
Contributor

adehad commented Oct 16, 2021

Side note: do you have trouble running the test server instance? For me, it fails almost every time. It only works if I add --network=host.

I personally haven't encountered any issues, although I'm no docker expert myself.
I am using a Windows machine, so can try and help if you have a similar setup.

I will try to open an issue about this, although the bug template is cumbersome with a lot of questions I can't answer.

Gotcha, I think there is an option hidden for opening a blank issue, so maybe give that a try:
image

These URLs it's complaining about open fine in a browser so I don't know why docker is failing.

Only thing I can think of is perhaps trying a specific version:

run: docker run -dit -p 2990:2990 --name jira addono/jira-software-standalone --version ${{ matrix.jira-version }}

So maybe something like this could work?

docker run -dit -p 2990:2990 --name jira addono/jira-software-standalone --version 8.17.1

@durka
Copy link
Contributor Author

durka commented Oct 17, 2021

This is apparently a very well kept secret, but it seems on Linux docker containers cannot access the internet at all by default: https://superuser.com/a/1582710/1271061

@adehad adehad merged commit 81b820c into pycontribs:main Oct 17, 2021
@adehad
Copy link
Contributor

adehad commented Oct 17, 2021

This is apparently a very well kept secret, but it seems on Linux docker containers cannot access the internet at all by default: https://superuser.com/a/1582710/1271061

hahah, classic

Thanks for your contribution, this is now merged !

@durka
Copy link
Contributor Author

durka commented Oct 17, 2021

Thanks :) I will be waiting for the next release so I can update the dependency in my project.

svermeulen pushed a commit to svermeulen/jira that referenced this pull request Oct 31, 2021
* also update `.rank()` to handle "agile" endpoint correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants