ServiceNow / servicenow-cicd-azure-extension

Extension for Azure Pipelines to help developers get started faster with ServiceNow's CI/CD APIs
MIT License
12 stars 18 forks source link

ServiceNow CI/CD Install Application - Application Version Issue #16

Closed ramyaramdasan closed 3 years ago

ramyaramdasan commented 3 years ago

Hi Chiarng,

When I have App 1.0.0 on my DEV instance (dev branch) and I use the dev branch to update the delta code to my test instance using ServiceNow CI/CD Install Application (ServiceNow-CICD-SC-Apply@1) extension, it installs 1.0.1 version.

When I choose to pick the application version from source (which I manually update in Application Settings prior to App Publish), why would I want the ServiceNow CI/CD Install Application step to increment the version for me? Is this an expected behavior?

vinay2099 commented 3 years ago

Hi Ramyaramdasan,

If you do not want the increment use the versionformat as detect_without_autoincrement (versionFormat: 'detect_without_autoincrement') This was updated in the latest release 1.7.0

ramyaramdasan commented 3 years ago

Hi Vinay,

I believe the version format is for Publish to App Repo. In the ServiceNow CI/CD Install Application extension to install application from source control repository (GitHub in my case), there is no version format that we can mention. Or is my understanding wrong? Can we use detect_without_autoincrement in this extension too?

vinay2099 commented 3 years ago

Hi Ramya,

How are you doing the publish.? If you are making in the pipeline, then use the version for app publish in pipeline and that should solve the issue. Ideally for install you just give sys_id as input and that installs the latest vesion.

ramyaramdasan commented 3 years ago

Hi Vinay,

The App Publish task (ServiceNow-CICD-App-Publish@1) is working as expected. I am referring to Install Application task(ServiceNow-CICD-SC-Apply@1) which does not have a versionformat input. And when I apply changes using this task, it increments the latest version by 1 and installs on the instance.

vinay2099 commented 3 years ago

Hi Ramya,

I am still in doubt how it will increase version without having that version in the app repository. Try to send input publishVersion with value. I believe that should work.

ramyaramdasan commented 3 years ago

The version we set under Application Settings (sys_app table) is also loaded into GitHub Repository as an application file when we commit the code into the repo, may be from there? I don't see any publishVersion input for this task.

vinay2099 commented 3 years ago

add that publishVersion : '{your version value}' under the appScope and give a try

ramyaramdasan commented 3 years ago

Sorry, I am not sure I understand it. I am new to Azure Pipelines. What is this syntax for - '{your version value}' how do I pass the latest version in here? The pipeline is auto-triggered when I commit code into the source control, so how can I pass this value?

vinay2099 commented 3 years ago

publishVersion : '1.0.0' (this 1.0.0 is version you wanted to install)

task: ServiceNow-CICD-SC-Apply@1 inputs: connectedServiceName: appSysId: branchName: appScope: publishVersion : '1.0.0'

chiarng commented 3 years ago

Hi @ramyaramdasan and @vinay2099, Just to clarify, the AppInstall task has a version parameter that is optional. If it's filled in, it'll try to install that version of the app from app repo. If it's NOT filled in, it will default to whichever version was published by the AppPublish task (or try to). https://github.com/ServiceNow/servicenow-cicd-azure-extension/blob/master/src/lib/AppInstall.js#L19 So @ramyaramdasan the behavior you are seeing is because the AppPublish task is first auto-incrementing the version to x.y.(z+1), that's why the AppInstall task is trying to install x.y.(z+1). Originally, this was intended to help automate pipelines by not requiring the developer to have to keep bumping up versioning, but in practice I'll admit it's been tough to use because the auto-incremented version isn't committed back to Source... I would actually love for somebody to fix that haha. @vinay2099 is correct that we recently added a new versionFormat value as an option to NOT auto-increment: https://github.com/ServiceNow/servicenow-cicd-azure-extension/releases/tag/1.7.0 So you can try to publish with the new "detect_without_autoincrement" option and then your AppInstall will do x.y.z. Hope that helps! :) Thanks, Chiarng

ramyaramdasan commented 3 years ago

Hi @chiarnglin ,

My Pipeline starts with a commit to GIT from DEV Studio. Pipeline updates TEST instance using AppInstall extension. Then ATF is run on TEST. If successful, we do AppPublish to AppRepo and update ACC using AppRepo. Now:

Step 1) I commit 1.0.0 from DEV Studio Step 2) Pipeline triggers. AppInstall updates TEST instance with 1.0.1

I still haven't published my app. The AppInstall is picking code from GIT, which has 1.0.0, but when it updates TEST, its incrementing the version.

Step 3) On successful ATF, applicaton is published from TEST, so App Repo gets version 1.0.1 as I have set it to 'detect'.

Going through AppInstall code, it looks like it is taking version details from AppPublish? But how would that work in a pipeline where AppInstall happens before AppPublish?

chiarng commented 3 years ago

@ramyaramdasan Hmm. Granted I haven't tried installing without publishing, but theoretically it should error out since there's no versions in the app repo to install from. The incrementing of versions should only happen on AppPublish. Let's take a look at your pipeline in closer detail on the Monday call. I'm wondering if somehow you have multiple stages of your pipeline simultaneously triggering on parallel, so AppPublish runs before AppInstall, somehow. Either that, or there's some random bug we have to go hunt down.

ramyaramdasan commented 3 years ago

Sure @chiarnglin . I am not talking about App Install from Repo. ServiceNow-CICD-SC-Apply@1 is the extension for ServiceNow CI/CD Apply Changes (code is picked from GIT Repository).