diff --git a/Pipfile b/Pipfile index d80ff30..2289992 100644 --- a/Pipfile +++ b/Pipfile @@ -6,7 +6,7 @@ verify_ssl = true [packages] flask = "~=2.3.0" requests = "~=2.32.3" -jira = "~=3.0.0" +jira = "~=3.8.0" logging-formatter-anticrlf = "~=1.2.1" [dev-packages] diff --git a/action.yml b/action.yml index 544f767..9edd65a 100644 --- a/action.yml +++ b/action.yml @@ -27,6 +27,10 @@ inputs: description: 'Which direction to synchronize in ("gh2jira", "jira2gh" or "both")' required: false default: 'both' + issue_state_key: + description: 'Name of the task that will contain the state file. If not provided it will be created a default one.' + required: false + default: '-' issue_end_state: description: 'Custom end state' required: false @@ -51,6 +55,7 @@ runs: INPUTS_SYNC_DIRECTION: ${{ inputs.sync_direction }} INPUTS_ISSUE_END_STATE: ${{ inputs.issue_end_state }} INPUTS_ISSUE_REOPEN_STATE: ${{ inputs.issue_reopen_state }} + INPUTS_ISSUE_STATE_KEY: ${{ inputs.issue_state_key }} run: | pip3 install pipenv pipenv install @@ -67,5 +72,6 @@ runs: --jira-project "$INPUTS_JIRA_PROJECT" \ --jira-labels "$INPUTS_JIRA_LABELS" \ --direction "$INPUTS_SYNC_DIRECTION" \ + --state-issue "$INPUTS_ISSUE_STATE_KEY" \ --issue-end-state "$INPUTS_ISSUE_END_STATE" \ --issue-reopen-state "$INPUTS_ISSUE_REOPEN_STATE" diff --git a/jiralib.py b/jiralib.py index a6bf0e9..771d2d4 100644 --- a/jiralib.py +++ b/jiralib.py @@ -1,4 +1,5 @@ from jira import JIRA +from io import StringIO import re import util import logging @@ -99,7 +100,6 @@ def create_hook( return resp.json() - class JiraProject: def __init__(self, jira, projectkey, endstate, reopenstate, labels): self.jira = jira @@ -161,9 +161,9 @@ def save_repo_state(self, repo_id, state, issue_key="-"): self.j.delete_attachment(a.id) # attach the new state file - self.jira.attach_file( - i.key, repo_id_to_fname(repo_id), util.state_to_json(state) - ) + attachment = StringIO() + attachment.write(util.state_to_json(state)) + self.j.add_attachment(issue=i, attachment=attachment, filename=repo_id_to_fname(repo_id)) def create_issue( self,