├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── batch_payload.json ├── workflow.yml ├── workflow_appcustomization.yml ├── workflow_batch_install.yml ├── workflow_publish_with_detect.yml └── workflow_scan_instance.yml /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contribution Model 2 | 3 | Contributions to help improve this integration are more than welcome. As is standard workflow, please fork the project to your own repo, create a branch to commit your changes to, then submit a pull request back to this project. An open-source community maintainer will then help to review the changes and merge the pull request if the changes are approved. A new version of the integration will then be published onto the respective marketplace. In your pull request, please include the following where applicable: 4 | 5 | 1. Description of the problem solved. Include Issue link if there is one. 6 | 2. Acceptance criteria for how an approver can tell if the "story" was completed. 7 | 8 | If your changes involve code, please update the unit tests as well. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ServiceNow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Starter Workflows for ServiceNow CI/CD using GitHub Actions 2 | 3 | These are the workflow files for helping people get started with GitHub Actions when building applications on the Now Platform. 4 | 5 | Just copy and paste into your pipeline once your workflow is created for your application's linked GitHub repo. 6 | 7 | The APIs the GitHub Actions are based on are [documented on the ServiceNow Developer Portal](https://developer.servicenow.com/dev.do#!/reference/api/sandiego/rest/cicd-api). 8 | 9 | ## Description of workflow templates 10 | - [workflow.yml](https://github.com/ServiceNow/sncicd_githubworkflow/blob/master/workflow.yml) Standard example to start from with 3 stages - build, test, deploy to prod. First two runs for CI on feature branch PR. All 3 run for CD on master branch update. 11 | - [workflow_publish_with_detect.yml](https://github.com/ServiceNow/sncicd_githubworkflow/blob/master/workflow_publish_with_detect.yml) Example for how to use the "detect" option with the ServiceNow/sncicd-publish-app GitHub Action. This is necessary for the repo source to be populated into the runner environment. 12 | - [workflow_scan_instance.yml](https://github.com/ServiceNow/sncicd_githubworkflow/blob/master/workflow_scan_instance.yml) Standard example to start working with Scan Instance action. 13 | - [workflow_batch_install.yml](https://github.com/ServiceNow/sncicd_githubworkflow/blob/master/workflow_batch_install.yml) Standard example to start working with Batch Install action. [Example of payload](https://github.com/ServiceNow/sncicd_githubworkflow/blob/master/batch_payload.json). 14 | 15 | ## Marketplace 16 | 17 | - https://github.com/marketplace/actions/servicenow-ci-cd-apply-changes 18 | - https://github.com/marketplace/actions/servicenow-ci-cd-install-app 19 | - https://github.com/marketplace/actions/servicenow-ci-cd-publish-app 20 | - https://github.com/marketplace/actions/servicenow-ci-cd-rollback-app 21 | - https://github.com/marketplace/actions/servicenow-ci-cd-run-atf-test-suite 22 | - https://github.com/marketplace/actions/servicenow-ci-cd-activate-plugin 23 | - https://github.com/marketplace/actions/servicenow-ci-cd-rollback-plugin 24 | - https://github.com/marketplace/actions/servicenow-ci-cd-batch-install 25 | - https://github.com/marketplace/actions/servicenow-ci-cd-instance-scan 26 | 27 | ## Repos 28 | - https://github.com/ServiceNow/sncicd-apply-changes 29 | - https://github.com/ServiceNow/sncicd-install-app 30 | - https://github.com/ServiceNow/sncicd-publish-app 31 | - https://github.com/ServiceNow/sncicd-rollback-app 32 | - https://github.com/ServiceNow/sncicd-tests-run 33 | - https://github.com/ServiceNow/sncicd-plugin-activate 34 | - https://github.com/ServiceNow/sncicd-plugin-rollback 35 | - https://github.com/ServiceNow/sncicd-batch-install 36 | - https://github.com/ServiceNow/sncicd-instance-scan 37 | 38 | ## Support Model 39 | 40 | ServiceNow built this integration with the intent to help customers get started faster in adopting CI/CD APIs for DevOps workflows, but __will not be providing formal support__. This integration is therefore considered "use at your own risk", and will rely on the open-source community to help drive fixes and feature enhancements via Issues. Occasionally, ServiceNow may choose to contribute to the open-source project to help address the highest priority Issues, and will do our best to keep the integrations updated with the latest API changes shipped with family releases. This is a good opportunity for our customers and community developers to step up and help drive iteration and improvement on these open-source integrations for everyone's benefit. 41 | 42 | ## Governance Model 43 | 44 | Initially, ServiceNow product management and engineering representatives will own governance of these integrations to ensure consistency with roadmap direction. In the longer term, we hope that contributors from customers and our community developers will help to guide prioritization and maintenance of these integrations. At that point, this governance model can be updated to reflect a broader pool of contributors and maintainers. 45 | -------------------------------------------------------------------------------- /batch_payload.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Batch name here", 3 | "notes": "Your notes here", 4 | "packages": [ 5 | { 6 | "id": "{{sys_id}}", 7 | "type": "application", 8 | "load_demo_data": false, 9 | "requested_version": "{{version}}", 10 | "requested_customization_version": "{{version}}", 11 | "notes": "{{notes}}" 12 | }, 13 | { 14 | "id": "{{sys_id}}", 15 | "type": "application", 16 | "load_demo_data": false, 17 | "requested_version": "{{version}}", 18 | "requested_customization_version": "{{version}}", 19 | "notes": "{{notes}}" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /workflow.yml: -------------------------------------------------------------------------------- 1 | name: ServiceNow GitHub Actions Demo 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | build: 11 | # Purpose of this job is to Apply Remote Changes for the branch triggering 12 | # the pipeline build to the Dev instance, then publish the application to 13 | # app repo using the template versioning format. 14 | name: Publish from Dev 15 | runs-on: ubuntu-latest 16 | # Below line can be used to set conditionals for modifying your pipeline as needed. 17 | # if: ${{ github.event_name == 'pull_request'}} 18 | 19 | steps: 20 | 21 | - name: ServiceNow CI/CD Apply Changes 22 | uses: ServiceNow/sncicd-apply-changes@2.0.0 23 | env: 24 | nowUsername: ${{ secrets.SN_USERNAME }} 25 | nowPassword: ${{ secrets.SN_PASSWORD }} 26 | nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} 27 | appSysID: ${{ secrets.SN_APP_SYSID }} 28 | 29 | - name: ServiceNow CI/CD Publish App 30 | id: publish_app 31 | uses: ServiceNow/sncicd-publish-app@2.0.1 32 | with: 33 | versionTemplate: 1.1 34 | versionFormat: template 35 | # Optional, add +X to version number. Default: 1 36 | # incrementBy: X 37 | env: 38 | nowUsername: ${{ secrets.SN_USERNAME }} 39 | nowPassword: ${{ secrets.SN_PASSWORD }} 40 | nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} 41 | appSysID: ${{ secrets.SN_APP_SYSID }} 42 | 43 | # This is required to pass the version number output from Publish App 44 | # to the input for Install App in the next job! This is because the jobs 45 | # run on different Linux instances, so without this Install App won't know 46 | # what to install. 47 | outputs: 48 | publishversion: ${{ steps.publish_app.outputs.newVersion }} 49 | 50 | test: 51 | # Purpose of this job is to Install App from the app repo for the version 52 | # published in the build job to a Test instance, then run an ATF Test Suite 53 | # associated with the app. If Test Suite fails, the app should be Rolled Back 54 | # to clean up the persistent Test environment. 55 | needs: build 56 | name: Run ATF in Test 57 | runs-on: ubuntu-latest 58 | # Below line can be used to set conditionals for modifying your pipeline as needed. 59 | # if: ${{ github.event_name == 'pull_request'}} 60 | 61 | steps: 62 | 63 | - name: ServiceNow CI/CD Install App 64 | id: install_app 65 | uses: ServiceNow/sncicd-install-app@2.0.0 66 | with: 67 | version: ${{ needs.build.outputs.publishversion }} 68 | # Only applicable if Application Customization is active. 69 | # Version of the base application on which to apply the customizations 70 | # baseAppVersion: '1.2.3' 71 | # Only applicable if Application Customization is active and the associated 72 | # application is a higher version than the currently installed version 73 | # Default: false 74 | autoUpgradeBaseApp: false 75 | env: 76 | nowUsername: ${{ secrets.SN_USERNAME }} 77 | nowPassword: ${{ secrets.SN_PASSWORD }} 78 | nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} 79 | appSysID: ${{ secrets.SN_APP_SYSID }} 80 | 81 | - name: ServiceNow CI/CD Run ATF Test Suite 82 | uses: ServiceNow/sncicd-tests-run@2.0.0 83 | with: 84 | testSuiteSysId: ${{ secrets.SN_ATFTESTSUITE_SYSID }} 85 | env: 86 | nowUsername: ${{ secrets.SN_USERNAME }} 87 | nowPassword: ${{ secrets.SN_PASSWORD }} 88 | nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} 89 | 90 | - name: ServiceNow CI/CD Rollback App 91 | if: ${{ failure() && steps.install_app.outputs.rollbackVersion }} 92 | uses: ServiceNow/sncicd-rollback-app@2.0.0 93 | with: 94 | version: ${{steps.install_app.outputs.rollbackVersion}} 95 | env: 96 | nowUsername: ${{ secrets.SN_USERNAME }} 97 | nowPassword: ${{ secrets.SN_PASSWORD }} 98 | nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} 99 | appSysID: ${{ secrets.SN_APP_SYSID }} 100 | 101 | # This is required to pass the version number output from Publish App 102 | # to the input for Install App in the next job! This is because the jobs 103 | # run on different Linux instances, so without this Install App won't know 104 | # what to install. 105 | outputs: 106 | publishversion: ${{ needs.build.outputs.publishversion }} 107 | 108 | deployprod: 109 | # Purpose of this job is to Install App to a Prod instance. This should only 110 | # trigger if the feature branch has been merged to master after a successfully 111 | # completed pull request, hence the conditional for push to master. In other words, 112 | # the first two jobs run on CI, then all three jobs run on CD. 113 | needs: test 114 | name: Deploy to Prod 115 | runs-on: ubuntu-latest 116 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} 117 | steps: 118 | 119 | - name: ServiceNow CI/CD Install App 120 | id: install_app_prod 121 | uses: ServiceNow/sncicd-install-app@2.0.0 122 | with: 123 | version: ${{ needs.test.outputs.publishversion }} 124 | # Only applicable if Application Customization is active. 125 | # Version of the base application on which to apply the customizations 126 | # baseAppVersion: '1.2.3' 127 | # Only applicable if Application Customization is active and the associated 128 | # application is a higher version than the currently installed version 129 | # Default: false 130 | # autoUpgradeBaseApp: true 131 | env: 132 | nowUsername: ${{ secrets.SN_USERNAME }} 133 | nowPassword: ${{ secrets.SN_PASSWORD }} 134 | nowInstallInstance: ${{ secrets.SN_PROD_INSTANCE }} 135 | appSysID: ${{ secrets.SN_APP_SYSID }} 136 | -------------------------------------------------------------------------------- /workflow_appcustomization.yml: -------------------------------------------------------------------------------- 1 | name: ServiceNow GitHub Actions Demo 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | publish: 11 | # Purpose of this job is to demonstrate publishing an Application Customization 12 | name: Publish from Dev 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: ServiceNow CI/CD Publish App 16 | id: publish_app 17 | uses: ServiceNow/sncicd-publish-app@2.0.1 18 | with: 19 | versionTemplate: 1.1 20 | versionFormat: template 21 | incrementBy: 1 22 | isAppCustomization: true 23 | env: 24 | nowUsername: ${{ secrets.SN_USERNAME }} 25 | nowPassword: ${{ secrets.SN_PASSWORD }} 26 | nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} 27 | appSysID: ${{ secrets.SN_APP_SYSID }} 28 | 29 | # This is required to pass the version number output from Publish App 30 | # to the input for Install App in the next job! This is because the jobs 31 | # run on different Linux instances, so without this Install App won't know 32 | # what to install. 33 | outputs: 34 | publishversion: ${{ steps.publish_app.outputs.newVersion }} 35 | 36 | install: 37 | # Purpose of this job is to demonstrate installing an Application Customization 38 | needs: publish 39 | name: Deploy to Prod 40 | runs-on: ubuntu-latest 41 | steps: 42 | 43 | - name: ServiceNow CI/CD Install App 44 | id: install_app_prod 45 | uses: ServiceNow/sncicd-install-app@1.0.0 46 | with: 47 | version: ${{ needs.publish.outputs.publishversion }} 48 | # Only applicable if Application Customization is active. 49 | # Version of the base application on which to apply the customizations 50 | baseAppVersion: '1.2.3' 51 | # Only applicable if Application Customization is active and the associated 52 | # application is a higher version than the currently installed version 53 | # Default: false 54 | autoUpgradeBaseApp: true 55 | env: 56 | nowUsername: ${{ secrets.SN_USERNAME }} 57 | nowPassword: ${{ secrets.SN_PASSWORD }} 58 | nowInstallInstance: ${{ secrets.SN_PROD_INSTANCE }} 59 | appSysID: ${{ secrets.SN_APP_SYSID }} 60 | -------------------------------------------------------------------------------- /workflow_batch_install.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | name: ServiceNow_Batch_Install 3 | # Controls when the action will run. 4 | on: 5 | # Triggers the workflow on push or pull request events but only for the master branch 6 | push: 7 | branches: [master] 8 | pull_request: 9 | branches: [master] 10 | # Allows you to run this workflow manually from the Actions tab 11 | workflow_dispatch: 12 | 13 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 14 | jobs: 15 | test: 16 | # Purpose of this job is to Install App to a Prod instance. This should only 17 | # trigger if the feature branch has been merged to master after a successfully 18 | # completed pull request, hence the conditional for push to master. 19 | name: Batch Install App 20 | runs-on: ubuntu-latest 21 | steps: 22 | # This step is Required if you 23 | # want to read manifest.json from your repo 24 | - name: Checkout 25 | uses: actions/checkout@v2 26 | - name: ServiceNow CI/CD Batch Install App 27 | uses: ServiceNow/sncicd-batch-install@2.0.1 28 | id: batch_install 29 | with: 30 | # Source of Data(file/workflow), Required 31 | source: file 32 | # Optional, manifest filename. Default: now_batch_manifest.json 33 | filename: manifest.json 34 | # Required if workflow source specified 35 | # Stringified json object 36 | manifest: '{"name": "Release Deployment","notes": "MyNotes","packages": [{"id": "123abc","type": "application","load_demo_data": false,"requested_version": "1.0.0","requested_customization_version": "1.0.1","notes": "MyNotes"}]}' 37 | env: 38 | nowUsername: ${{ secrets.NOW_USERNAME }} 39 | nowPassword: ${{ secrets.NOW_PASSWORD }} 40 | nowInstallInstance: ${{ secrets.NOW_CLIENT_INSTANCE }} 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /workflow_publish_with_detect.yml: -------------------------------------------------------------------------------- 1 | # This workflow file shows an example of how to use ServiceNow/sncicd-publish-app. 2 | # You have to first use actions/checkout@v2 to populate the GITHUB_WORKFLOW environment variable. 3 | 4 | name: ServiceNow GitHub Actions Demo 5 | 6 | on: 7 | pull_request: 8 | push: 9 | branches: 10 | - master 11 | 12 | jobs: 13 | build: 14 | # Purpose of this job is to Apply Remote Changes for the branch triggering 15 | # the pipeline build to the Dev instance, then publish the application to 16 | # app repo using the template versioning format. 17 | name: Publish from Dev 18 | runs-on: ubuntu-latest 19 | # Below line can be used to set conditionals for modifying your pipeline as needed. 20 | # if: ${{ github.event_name == 'pull_request'}} 21 | 22 | steps: 23 | 24 | - name: ServiceNow CI/CD Apply Changes 25 | uses: ServiceNow/sncicd-apply-changes@1.0.0 26 | env: 27 | nowUsername: ${{ secrets.SN_USERNAME }} 28 | nowPassword: ${{ secrets.SN_PASSWORD }} 29 | nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} 30 | appSysID: ${{ secrets.SN_APP_SYSID }} 31 | 32 | - uses: actions/checkout@v2 33 | 34 | - name: ServiceNow CI/CD Publish App 35 | id: publish_app 36 | uses: ServiceNow/sncicd-publish-app@1.1.0 37 | with: 38 | # versionTemplate: 1.2 39 | versionFormat: detect 40 | # Optional, add +X to version number. Default: 1 41 | # incrementBy: X 42 | env: 43 | nowUsername: ${{ secrets.SN_USERNAME }} 44 | nowPassword: ${{ secrets.SN_PASSWORD }} 45 | nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} 46 | appSysID: ${{ secrets.SN_APP_SYSID }} 47 | 48 | # This is required to pass the version number output from Publish App 49 | # to the input for Install App in the next job! This is because the jobs 50 | # run on different Linux instances, so without this Install App won't know 51 | # what to install. 52 | outputs: 53 | publishversion: ${{ steps.publish_app.outputs.newVersion }} 54 | -------------------------------------------------------------------------------- /workflow_scan_instance.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | name: ServiceNow_Scan_Instance 3 | # Controls when the action will run. 4 | on: 5 | # Triggers the workflow on push or pull request events but only for the master branch 6 | push: 7 | branches: [master] 8 | pull_request: 9 | branches: [master] 10 | # Allows you to run this workflow manually from the Actions tab 11 | workflow_dispatch: 12 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 13 | jobs: 14 | test: 15 | # Purpose of this job is to Scan Instance. This should only 16 | # trigger if the feature branch has been merged to master after a successfully 17 | # completed pull request, hence the conditional for push to master. 18 | name: Scan App 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: ServiceNow CI/CD Instance Scan 23 | uses: ServiceNow/sncicd-instance-scan@2.0.0 24 | id: scan 25 | with: 26 | # scantype is always Required 27 | scantype: full # point, suite_combo, suite_scoped, suite_update 28 | # Required on point 29 | targetTable: abcdef 30 | targetSysId: 1a2b3c4d5e6f 31 | # Required on suite_combo 32 | comboSysId: 1a2b3c4d5e6f 33 | # Required on suite_scoped, suite_update 34 | suiteSysId: 1a2b3c4d5e6f 35 | # Required on suite_scoped 36 | appScopeSysIds: 1a2b3c,4d5e6f 37 | # Required on suite_update 38 | updateSetSysIds: 1a2b3c,4d5e6f 39 | env: 40 | nowUsername: ${{ secrets.NOW_USERNAME }} 41 | nowPassword: ${{ secrets.NOW_PASSWORD }} 42 | nowScanInstance: ${{ secrets.NOW_SCAN_INSTANCE }} 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | --------------------------------------------------------------------------------