-
Notifications
You must be signed in to change notification settings - Fork 216
USHFT-2969: Release notes job: use token for git
commands
#3236
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
USHFT-2969: Release notes job: use token for git
commands
#3236
Conversation
@pmtk: No Jira issue with key USHFT-2969 exists in the tracker at https://issues.redhat.com/. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/assign @dhellmann |
env = {} | ||
env.update(os.environ) | ||
|
||
print(f'git remote remote {REMOTE}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(f'git remote remote {REMOTE}') | |
print(f'git remote remove {REMOTE}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, thx!
@@ -404,6 +407,28 @@ def tag_exists(release_name): | |||
return False | |||
|
|||
|
|||
def add_token_remote(): | |||
""" | |||
Returns the Git remote for the given repository using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns the Git remote for the given repository using | |
Adds the Git remote to the given repository using |
@@ -486,14 +511,18 @@ def publish_release(new_release, take_action): | |||
# Create draft release with message that includes download URLs and history | |||
try: | |||
github_release_create(release_name, notes) | |||
except urllib.error.URLError as e: | |||
print(f"Failed to create the release {release_name}: {e}") | |||
print(f"Response: {str(e.fp.readlines())}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add response printout the to catch-all handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a different type so it doesn't have these fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain when this exception is thrown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it when I tested and the release was already present. Original log would only say: Failed to create the release 4.16.0-ec.1-202401101824.p0: HTTP Error 422: Unprocessable Entity
and the hint that there already was a release was in the response body of the HTTP request.
But I suspect this exception could happen any other time that HTTP request wasn't successful (i.e. 200) and without response's body we have not enough info to work on it.
926b1e2
to
6cec94b
Compare
/retest |
6cec94b
to
4854bfb
Compare
When ci-operator clones the repository it does not include any credentials to talk back to the repository. To be able to execute `git push` we need to add a special remote that will use token that is either supplied (Personal) or generated (installation access token).
4854bfb
to
8874b1a
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
) | ||
if result.returncode != 0: | ||
err = result.stderr.replace(GITHUB_TOKEN, "") if result.stderr else "stderr is empty" | ||
raise Exception(f"Command `git remote add` failed: {err}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use CalledProcessError, like on line 459, but I wouldn't hold this up over it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed it, but didn't quite fit here - I didn't want to put cmd
in there and redact two things
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dhellmann, pmtk The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@pmtk: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
When ci-operator clones the repository it does not include any credentials to talk back to the repository.
To be able to execute
git push
we need to add a special remote that will use token that is either supplied (personal) or generated (Installation Access Token, IAT).