Track CDM changesets
List configuration-data changesets and check the status of a commit.
When to use this pattern
- You're automating a CDM promotion pipeline and need to gate on commit status
- You're auditing which changesets touched a deployable
Required values
| Value | Description |
|---|---|
| Commit ID | For status checks: the commit you're waiting on |
Example
package main
import (
"context"
"fmt"
"log"
servicenow "github.com/michaeldcanady/servicenow-sdk-go/v2"
"github.com/michaeldcanady/servicenow-sdk-go/v2/credentials"
)
func main() {
// Step 1: Authenticate and initialize the client
cred := credentials.NewBasicProvider("{username}", "{password}")
client, err := servicenow.NewServiceNowServiceClient(
servicenow.WithAuthenticationProvider(cred),
servicenow.WithInstance("{instance}"),
)
if err != nil {
log.Fatalf("failed to initialize client: %v", err)
}
ctx := context.Background()
changesets := client.Cdm().Changesets()
// Step 2: List changesets
response, err := changesets.Get(ctx, nil)
if err != nil {
log.Fatalf("unable to list changesets: %v", err)
}
list, err := response.GetResult()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d changesets\n", len(list))
// Step 3: Check the status of a commit
status, err := changesets.CommitStatus().ByID("{SysID}").Get(ctx, nil)
if err != nil {
log.Fatalf("commit status failed: %v", err)
}
fmt.Printf("commit status: %+v\n", status)
}
Tips
ByID(changesetSysID).ImpactedDeployables()shows what a changeset affects before you commit it.