Hello! I have set up a couple of pipelines in azure using this suggested approach:
opened 11:42AM - 17 Aug 21 UTC
docs 📝
triage
## Description
Currently the documentation for adding rover cli checks and pu… blishing a federated schema to a CI/CD pipeline are missing for Azure DevOps.
Following is a yaml template that can be dropped in for Azure DevOps scenarios.
Note the template assumes an authenticated Azure DevOps Artifact feed is used.
This template works by using npm install to make the rover cli available during ci/cd.
After installing rover the script first runs 'rover graph check' and causes the job to fail on schema errors.
After check is successfull the script publishes the schema to Apollo Studio.
```yaml
parameters:
- name: jobName
type: string
- name: supergraph
type: string
- name: subgraph
type: string
- name: subgraphRoutingUrl
type: string
- name: schemaFileLocation
type: string
- name: variables
type: object
default: []
- name: pool
type: string
- name: npmrcLocation
type: string
default: '.npmrc'
- name: checkOnly
type: boolean
default: true
- name: dependsOn
type: string
default: ''
######################################################################################################
####### Parameters #########
######################################################################################################
# jobName: Name of the job
# supergraph: Name of the apollo supergraph including variant, e.g. Supergraph@test
# subgraph: Name of the apollo subgraph that is to be checked and updated
# subgraphRoutingUrl: The url to the subgraph
# schemaFileLocation: Location of the .graphql schema file
# variables: (Optional) Variables to be passed in
# pool: (Optional) Pool of the agent to run on
# npmrcLocation: (Optional) The npmrc file to use
# checkOnly: (Optional) If only a schema check should be performed, default true.
# dependsOn: (Optional) Name of the job, this depends on before executing. Default is ''.
jobs:
- job: Job_${{ parameters.jobName }}
displayName: Check and publish subgraph ${{ parameters.subgraph }} for ${{ parameters.supergraph }}
${{ if gt(length(parameters.dependsOn), 0) }}:
dependsOn: ${{ parameters.dependsOn }}
pool: ${{ parameters.pool}}
variables:
- ${{ if gt(length(parameters.variables), 0) }}:
- ${{ each var in parameters.variables }}:
- name: ${{ var.name }}
value: ${{ var.value }}
steps:
- checkout: self
- task: npmAuthenticate@0
inputs:
workingFile: ${{parameters.npmrcLocation}}
- task: Npm@1
inputs:
command: 'install'
- script: npx rover subgraph check ${{parameters.supergraph}} --name ${{parameters.subgraph}} --schema ${{parameters.schemaFileLocation}}
- ${{ if eq(parameters.checkOnly, false) }}:
- script: npx rover subgraph publish ${{parameters.supergraph}} --name ${{parameters.subgraph}} --routing-url ${{parameters.subgraphRoutingUrl}} --schema ${{parameters.schemaFileLocation}}
```
## usage of the template:
- Add a '.npmrc' file to the root of the project
- Add a 'packages.json' that defines '@apollo/rover' as a dependency
```yaml
jobs:
- template: /Check_and_Publish_Subgraph_v1.yml
parameters:
jobName: Publish_Subgraph_Test
supergraph: $(apolloSupergraph)@test
subgraph: $(apolloSubgraph)
subgraphRoutingUrl: '$(subgraphUrl)/$(apolloSubgraph)/graphql'
schemaFileLocation: $(schemaFileLocation)
variables:
- name: APOLLO_KEY
value: $(apolloKey)
pool: $(pool)
```
This has worked fine with a bunch of .NET HotChocolate services, aswell as with some node.js backends. However, now when we tried to setup the same approach with golang we run in to some permission issues:
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/95fbe295-3e6d-4769-86fc-37b1de3b2017.sh
sh: 1: rover: Permission denied
##[error]Bash exited with code '126'.
Any suggestions what might be wrong here? All pipelines are using the same vm image (ubuntu-latest). So can’t really figure why this service doesn’t work.
Any help or pointing in the right direction would be appreciated!
/Martin
Ended up installing the rover CLI via bash in the pipeline and calling that instead of the NPM / NPX command - which worked without issues.
vaikzs
March 14, 2023, 3:25am
3
facing the same issue with:
curl -sSL https://rover.apollo.dev/nix/v0.13.0 | sh