Skip to content

Conversation

@gayanW
Copy link
Contributor

@gayanW gayanW commented Sep 8, 2025

This PR extends --link option to support both the formats "kind|title=url" and "title=url"

Example usages:

Custom links:

launchable record build --name $build --link 'Title 1=https://google.com' --link 'Title 2=https://bing.com'`

Invalid kind:

$ launchable record build --name $build --link 'GITHUB_PR|PR=https://github.com/launchableinc/cli/pull/1'
Invalid kind 'GITHUB_PR' passed to --link option.
Supported kinds are: ['CUSTOM_LINK', 'JENKINS', 'GITHUB_ACTIONS', 'GITHUB_PULL_REQUEST', 'CIRCLECI']

Invalid URL for kind:

$ launchable record build --name $build --link 'GITHUB_PULL_REQUEST|PR=https://github.com/launchableinc/cli/pull/1/files'
Invalid url 'https://github.com/launchableinc/cli/pull/1/files' passed to --link option.
URL doesn't match with the specified kind: GITHUB_PULL_REQUEST

Infer kind:

$ launchable record build --name $build --link PR=https://github.com/launchableinc/cli/pull/1

GitHub PR links are automatically inferred as GITHUB_PULL_REQUEST.

Prioritize link options over env links:

$ GITHUB_PULL_REQUEST=https://github.com/launchableinc/cli/pull/1
$ launchable record build --name $build --link 'GITHUB_PULL_REQUEST|PR=https://github.com/launchableinc/cli/pull/2'

Here GITHUB_PULL_REQUEST URL passed in the link option will be used instead of the URL set via the environment variable.

@launchable-app

This comment has been minimized.

@gayanW gayanW requested review from kohsuke and ono-max September 8, 2025 09:53
@ono-max
Copy link
Contributor

ono-max commented Sep 9, 2025

I'll review this PR by this weekend.

@ono-max
Copy link
Contributor

ono-max commented Sep 10, 2025

Can you add the prefix _ to the private methods for expressing they're private?

e.g. https://github.com/cloudbees-oss/smart-tests-cli/blob/main/launchable/testpath.py#L46

for k, url in link_options:
# if k,v in format "kind|title=url"
if '|' in k:
kind, title = k.split('|', 1)
Copy link
Contributor

@ono-max ono-max Sep 10, 2025

Choose a reason for hiding this comment

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

Should we handle the whitespace?

e.g. GITHUB_PULL_REQUEST | PR = https://github.com/launchableinc/cli/pull/2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a strong opinion on this. I stripped the values to be forgiving to user error.

CIRCLECI_BUILD_NUM_KEY = 'CIRCLE_BUILD_NUM'
CIRCLECI_JOB_KEY = 'CIRCLE_JOB'

GITHUB_PR_REGEX = re.compile(r"^https://github\.com/[^/]+/[^/]+/pull/\d+$")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the named group? Here is the example:

>>> p = re.compile(r'(?P<word>\b\w+\b)')
>>> m = p.search( '(((( Lots of punctuation )))' )
>>> m.group('word')
'Lots'
>>> m.group(1)
'Lots'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we are not extracting any parts of the URL, I think it's better to keep it simple.

@gayanW gayanW merged commit e986505 into v1 Sep 11, 2025
13 checks passed
@gayanW gayanW deleted the LCHUX-181 branch September 11, 2025 01:39
Konboi added a commit that referenced this pull request Sep 22, 2025
Konboi added a commit that referenced this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants