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

GitHub repos named .github and .github-private are not supported #8499

Open
haysclark opened this issue Jan 6, 2023 · 3 comments
Open

GitHub repos named .github and .github-private are not supported #8499

haysclark opened this issue Jan 6, 2023 · 3 comments

Comments

@haysclark
Copy link

haysclark commented Jan 6, 2023

Summary

GitHub supports two special case repos for Customizing your organization's profile and other functionality, which must be named .github or .github-private. Currently, Jenkins-X only supports repo names that are valid Kubernetes Labels

The relevant error message (mentioned below) outputs the following RegEx: (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?

This issue manifests after Pipelines are triggered by Lighthouse and are being executed on a Build Pod. The jx-variables Step fails to find a Build number often resulting in a successful Pipeline run with no recorded Pipeline Activity.

Steps to reproduce the behavior

  • import any jx quickstart project (I'm using nodeJS) with a repo name that starts with a period. e.g. .github or .dottest
  • wait for import PR to be verified and committed. (note jx import CLI command will likely timeout due to the same issue)
  • create a PR
  • see the error mentioned below in PR's build Pod logs

Build Pod's log information must be collected via K8 Pod directly. I'm using k9s.

build Pod's log snippet

step-jx-variables Cloning into '/tmp/jx-git-4238811120'...
step-jx-variables error: failed to validate: failed to find build number: failed to find BuildNumber: failed to lazily create PipelineActivity myorg-github-private-pr-1-1: PipelineActivity.jenkins.io "myorg-github-private-pr-1-1" is invalid: metadata.labels: Invalid value: ".github-private": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
step-jx-variables added variables to file: .jx/variables.sh

🔎 Just the error message, broken out with line breaks

error: failed to validate: failed to find build number: failed to find BuildNumber: failed to lazily create 
PipelineActivity myorg-github-private-pr-1-1: PipelineActivity.jenkins.io "myorg-github-private-pr-1-1"
is invalid: metadata.labels: Invalid value: ".github-private": a valid label must be an empty string or 
consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character 
(e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is 
'(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

Expected behavior

The jx dashboard should show progress and log information for Pipeline.

Actual behavior

No Pipeline activity is recorded in jx dashboard, due to jx gitops variables step failing to "failed to find BuildNumber".

Jx version

The output of jx version is:

~ jx version
version: 3.10.10                                                                                                                                                             ─╯
shaCommit: c687e1c2deeed5970fbfdd55a4ef0d0c206bc51e
buildDate: Thu Nov  3 14:39:27 UTC 2022
goVersion: 1.19.3
branch: main
gitTreeState: clean
@haysclark haysclark changed the title GitHub repo names .github and .github-private are not supported due to limiting supported repo names to GitLab min spec GitHub repos named .github and .github-private are not supported due to limiting supported repo names to GitLab min spec Jan 6, 2023
@haysclark haysclark changed the title GitHub repos named .github and .github-private are not supported due to limiting supported repo names to GitLab min spec GitHub repos named .github and .github-private are not supported due to limiting repo names to GitLab min spec Jan 6, 2023
@haysclark haysclark changed the title GitHub repos named .github and .github-private are not supported due to limiting repo names to GitLab min spec GitHub repos named .github and .github-private are not supported Jan 6, 2023
@haysclark
Copy link
Author

Somewhat related PR - jenkins-x-plugins/jx-gitops#287

@haysclark
Copy link
Author

haysclark commented Mar 10, 2023

In regards to this error example:

error: failed to validate: failed to find build number: failed to find BuildNumber: failed to lazily create 
PipelineActivity myorg-github-private-pr-1-1: PipelineActivity.jenkins.io "myorg-github-private-pr-1-1"
is invalid: metadata.labels: Invalid value: ".github-private": a valid label must be an empty string or 
consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character 
(e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is 
'(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

The source of the issue appears to stem from the normalizing of names and/or labels in the PipelineRun which results in an error downstream when the logic tries to generate a PipelineActivities and can not find any PipelineRuns with a matching repo name.

When digging down the logic, it seems like much of the code paths end up using the ToValidValue helper method in the naming module of jenkins-x/jx-helpers, which ends up stripping characters like ..

.e.g. the name or label generated for repo: github.com/myorg/.github-private.git ends up being myorg-github-private

What I experienced locally, is that JX3 correctly triggers a PipelineRun for the .github-private repo, which functions as expected. However, no PipelineActivity k8 object is never generated as that logic fails to find a PipelineRun for .github-private as all the PipelineRun labels have been sanitized too: github-private.

At least that is what appears to be occurring...

@haysclark
Copy link
Author

The workaround we are currently using is simply to use GitHub Actions for linting the .github and .github-private repos. The repos are still imported into JX3; however, I've removed the .lighthouse folder so that we can still utilize JX3 for ChatOps.

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

No branches or pull requests

1 participant