Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
100 stars 28 forks source link

Adding a job to execute after CI completes #5156

Open mohamedghozzi-lw opened 3 years ago

mohamedghozzi-lw commented 3 years ago

Description of your issue:

I am trying to create a job that executes once CI jobs are finished. It is something similar to what is described here: https://github.com/Shippable/support/issues/3778

Issues: 1) I do not see the Hook under Project Actions -> Connect Pipelines 2) I tried to add the syncRepo as note here https://github.com/Shippable/support/issues/3778#issuecomment-323807269

I get a popup error "Please make sure subscription integration used to add syncRepo has admin access on project: xxxxxxxxxxxx

I am trying to import the YAML file with CI section and jobs section in a single file on our github repo

3) Under SPOG, I do not see my project ciRepo and runCI objects.

Please let me know what needs to be done to add the job. Thanks!

a-murphy commented 3 years ago

It sounds like there are a two different questions here, how to add the syncRepo and how to connect a CI job to an Assembly Line.

Issues 1 and 3 relate to making sure that an Assembly Line can connect to a particular CI job. Another way to tell if a CI project is an older project that hasn't yet been updated to run in Assembly Lines is by the format of the name on the subscription dashboard. If the name shown in the table includes the subscription name, then that project has not yet been updated, won't be visible in Assembly Lines, and should have a "hook" button in the second-to-last panel of the project settings. If the name shown doesn't include the subscription name, it has already been updated and you should be able to add it to Assembly Lines as described in http://docs.shippable.com/platform/workflow/job/runci/.

Directions to add a syncRepo are available here: http://docs.shippable.com/platform/tutorial/workflow/add-assembly-line/ You will need to have a subscription integration that has admin access to the repository in order to be able to create webhooks. This means a subscription integration that links to the SCM account integration of an account that is able to see the webhooks list on the source provider.

mohamedghozzi-lw commented 3 years ago

@a-murphy Thank you for your response!

  1. Issue 1 has been addressed. I am using a non-admin shippable account. So the 'Hook' button does not appear for me in the project settings. The account administrator has clicked the the 'Hook' button for me.
  2. Now under SPOG, I see the project runCI object but not the ciRepo. I am not sure if this is an issue.

Screen Shot 2020-10-23 at 11 49 13 AM

Now I am trying add a 'runSh' job following the completion of the CI job. I added this section to the shippable.yml file:

jobs:

The CI section of the shippable.yml builds the agent and completes successfully but the runSh job is never triggered. Based on my understating of the documentation, adding the job to the YAML file is all what is needed in my case. Please help me understand what I am missing.

  1. Regarding issue 2 about syncRepo. Is it needed for what I am trying to do? The article below has no mention for syncRepo to use the runCI to interact with other jobs http://docs.shippable.com/platform/workflow/job/runci/

The only reason I tried to add it is following the comment https://github.com/Shippable/support/issues/3778#issuecomment-323807269

a-murphy commented 3 years ago

Assembly Lines are defined in syncRepos, so, in order to add a runSh job, you'll need to add the repository containing the runSh definition as a syncRepo.

mzeier commented 3 years ago

@a-murphy - I think we're hitting a permissions isssue with the existing GitHub API token key but I don't know how to confirm the permissions for this API token in GitHub.

I can create a new personal access token but I'm not clear which permissions bits in GitHub need to be enabled. Guidance or a pointer to a doc I'm missing?

a-murphy commented 3 years ago

The GitHub scope to enable webhooks is admin:repo_hook and it would also need repo to see private repositories. However, GitHub integrations are expected to be OAuth tokens and I can't be sure if future webhooks would trigger a syncRepo sync correctly with a personal access token. Typically, SCM integrations are added to a subscription by selecting the "use an account integration" option and selecting the OAuth SCM integration created by logging into Shippable as that account. Creating a GitHub account to use for integrations allows the repositories accessible through the integration to be controlled.