ServiceNow / sncicd-publish-app

MIT License
8 stars 7 forks source link

ENOENT: no such file or directory, open '/home/runner/work/repo-name/repo-name/sys_app_***.xml' #3

Closed ramyaramdasan closed 3 years ago

ramyaramdasan commented 3 years ago

Hi @chiarnglin

When I tried to use 'detect' as versionFormat, I am getting the following error: ENOENT: no such file or directory, open '/home/runner/work/repo-name/repo-name/sysapp***.xml'

Below is the code snippet of how I have the Publish App step in my workflow file.

ramyaramdasan commented 3 years ago

Hi @chiarnglin ,

It looks like we will have to use 'detect' option for this Action in our pipeline as teams would set the version manually to track major release/ minor release/ hotfixes. other options probably pick the existing version and auto-increment it.

Is there a possibility that we get this issue fixed?

chiarng commented 3 years ago

@ramyaramdasan Can you check that this particular app has the sys_app record still? I know we have that other Support Case going to fix the sys_app record being deleted on some commits. Our engineering team found the root cause for that and we're backporting that fix.

Reason I ask is because when I look at the actual method for that detect option, it should only be failing if for whatever reason it can't find the Source. https://github.com/ServiceNow/sncicd-publish-app/blob/735428ed343235f8e56bc60c578692a4a6a1f87e/lib/src/App.js#L302

Unless you're saying that this option is just completely broken, then I'll need to add this to the (growing) pile of things we need to have our contractors fix. :)

ramyaramdasan commented 3 years ago

Hi @chiarnglin ,

Thank you for looking into this. I just checked the repository for the commit that threw this error. Yes, the sys_app record existed in its place at that point of time and it continues to exist.

Thanks Ramya

chiarng commented 3 years ago

Just noting that I was able to reproduce the error with a very basic app setup.

2021-01-22T15:51:08.9332070Z ##[section]Starting: Request a runner to run this job
2021-01-22T15:51:09.2006060Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-latest'
2021-01-22T15:51:09.2006169Z Can't find any online and idle self-hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2021-01-22T15:51:09.2006607Z Found online and idle hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2021-01-22T15:51:09.3995186Z ##[section]Finishing: Request a runner to run this job
2021-01-22T15:51:19.2180973Z Current runner version: '2.276.0'
2021-01-22T15:51:19.2207454Z ##[group]Operating System
2021-01-22T15:51:19.2208398Z Ubuntu
2021-01-22T15:51:19.2208809Z 18.04.5
2021-01-22T15:51:19.2209156Z LTS
2021-01-22T15:51:19.2209661Z ##[endgroup]
2021-01-22T15:51:19.2210141Z ##[group]Virtual Environment
2021-01-22T15:51:19.2210619Z Environment: ubuntu-18.04
2021-01-22T15:51:19.2211093Z Version: 20201210.0
2021-01-22T15:51:19.2211812Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu18/20201210.0/images/linux/Ubuntu1804-README.md
2021-01-22T15:51:19.2212467Z ##[endgroup]
2021-01-22T15:51:19.2213578Z Prepare workflow directory
2021-01-22T15:51:19.2383550Z Prepare all required actions
2021-01-22T15:51:19.2392330Z Getting action download info
2021-01-22T15:51:19.4786186Z Download action repository 'ServiceNow/sncicd-apply-changes@1.0.0'
2021-01-22T15:51:21.2121597Z Download action repository 'ServiceNow/sncicd-publish-app@1.0.0'
2021-01-22T15:51:21.7658053Z ##[group]Run ServiceNow/sncicd-apply-changes@1.0.0
2021-01-22T15:51:21.7658569Z env:
2021-01-22T15:51:21.7659225Z   snowUsername: ***
2021-01-22T15:51:21.7659594Z   snowPassword: ***
2021-01-22T15:51:21.7659972Z   snowSourceInstance: ***
2021-01-22T15:51:21.7660363Z   appSysID: ***
2021-01-22T15:51:21.7660640Z ##[endgroup]
2021-01-22T15:51:22.7319045Z Pending
2021-01-22T15:51:26.0763866Z Running: 5%
2021-01-22T15:51:29.4813331Z Running: 24%
2021-01-22T15:51:36.0022129Z This operation succeeded
2021-01-22T15:51:36.0022906Z Successfully applied commit ce9ba2c49dd6bc377f1524ba189f9452e0237a0b from source control
2021-01-22T15:51:36.0023533Z Successful
2021-01-22T15:51:36.0117284Z ##[group]Run ServiceNow/sncicd-publish-app@1.0.0
2021-01-22T15:51:36.0117778Z with:
2021-01-22T15:51:36.0118174Z   versionFormat: detect
2021-01-22T15:51:36.0118534Z env:
2021-01-22T15:51:36.0119208Z   snowUsername: ***
2021-01-22T15:51:36.0119694Z   snowPassword: ***
2021-01-22T15:51:36.0120186Z   snowSourceInstance: ***
2021-01-22T15:51:36.0120700Z   appSysID: ***
2021-01-22T15:51:36.0121087Z ##[endgroup]
2021-01-22T15:51:36.5697864Z Looking in /home/runner/work/bugtester/bugtester/
2021-01-22T15:51:36.5711372Z ##[error]ENOENT: no such file or directory, open '/home/runner/work/bugtester/bugtester/sys_app_***.xml'
2021-01-22T15:51:36.5786833Z Evaluate and set job outputs
2021-01-22T15:51:36.5793592Z Cleaning up orphan processes
chiarng commented 3 years ago

I'm like 95% sure it's because the dir path is wrong.

/bugtester/bugtester/sysapp***.xml

versus

/bugtester/8237f3221bf5ec90fe0165f8bc4bcbcd/sysapp***.xml

chiarng commented 3 years ago

So I think the core issue is because in Paris, a change was made to the the app dir path for scoped apps so that sysapp***.xml lives in a dir named after the sys_id (8237f3221bf5ec90fe0165f8bc4bcbcd) rather than the scope (x_cross_bugtester) as was the behavior in Orlando, but I'm not sure why we're using the name of the app (bugtester) here instead either.

chiarng commented 3 years ago

https://github.com/ServiceNow/sncicd-publish-app/pull/7

chiarng commented 3 years ago

Error: ENOENT: no such file or directory, open '/home/runner/work/bugtester/bugtester/***/sys_app_***.xml'

Oops.

chiarng commented 3 years ago

Fixed. Workflow needs to use actions/checkout per https://docs.github.com/en/actions/reference/environment-variables. Example:

name: ServiceNow GitHub Actions Demo

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  build:
    # Purpose of this job is to Apply Remote Changes for the branch triggering 
    # the pipeline build to the Dev instance, then publish the application to 
    # app repo using the template versioning format. 
    name: Publish from Dev
    runs-on: ubuntu-latest
    # Below line can be used to set conditionals for modifying your pipeline as needed.
    # if: ${{ github.event_name == 'pull_request'}}

    steps:

      - name: ServiceNow CI/CD Apply Changes
        uses: ServiceNow/sncicd-apply-changes@1.0.0
        env:
          snowUsername: ${{ secrets.SN_USERNAME }}
          snowPassword: ${{ secrets.SN_PASSWORD }}
          snowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }}
          appSysID: ${{ secrets.SN_APP_SYSID }}

      - uses: actions/checkout@v2

      - name: ServiceNow CI/CD Publish App
        id: publish_app
        uses: ServiceNow/sncicd-publish-app@1.1.0
        with:
          # versionTemplate: 1.2
          versionFormat: detect
        env:
          snowUsername: ${{ secrets.SN_USERNAME }}
          snowPassword: ${{ secrets.SN_PASSWORD }}
          snowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }}
          appSysID: ${{ secrets.SN_APP_SYSID }}

    # This is required to pass the version number output from Publish App 
    # to the input for Install App in the next job! This is because the jobs 
    # run on different Linux instances, so without this Install App won't know
    # what to install.
    outputs:
      publishversion: ${{ steps.publish_app.outputs.newVersion }}
chiarng commented 3 years ago

@ramyaramdasan

Example of successfully using version v1.1.0 with actions/checkout. image