Azure DevOps Pull request with Config As Code

We use Azure DevOps Server (on-prem) for out git repos and build pipelines. We are using Octopus (on-prem) version 2022.1.2488. As part of the pull request process, we run the build pipeline and then deploy (via octopus) to our Dev environment. From our build pipeline we use octo.exe (version 8.0.1) to create a release. Now that we have converted a project to Config as Code, the create-release step is failing. We have added the --gitRef and --gitCommit parameters, however they are ephemeral during the checkout source step in the build to make sure the PR merge to master will succeed. What do you suggest? I am assuming the --gitRef and --gitCommit parameters indicate which version of the ocl files to use, is that correct?


Hi Leslie,

Yes, You are spot on with the OCL version determined by --gitRef and --gitCommit.

We have a breakdown of the -gitRef and --gitCommands and when you should use them, over here: Creating and deploying releases on a version-controlled project - Octopus Deploy

Can you provide any further details about the actual error that your getting?
Are you getting an error message at all or can you provide some server logs?
I can convert this ticket to a private message if you you are concerned with your logs being available to the public.


Here is what I am seeing in the log files:

2022-04-29T06:46:52.5022306Z About to run createRelease command: & “C:\ProgramData\chocolatey\lib\OctopusTools\tools\Octo.exe” create-release --outputformat json --enableServiceMessages --project “AWSOctopus” --version --server XXXX --package=“AWSOctopus”: --gitCommit f30f2ec61693ba755777984b16e34e991678fd3a --gitRef refs/pull/34522/merge --apikey XXXXX
2022-04-29T06:46:57.1156234Z WARNING: Error creating release for project AWSOctopus
2022-04-29T06:46:57.5128980Z Create-OctopusRelease : Found environments:
2022-04-29T06:46:57.5129442Z Found project: AWSOctopus (Projects-21)
2022-04-29T06:46:57.5129894Z No git resource with the name ‘f30f2ec61693ba755777984b16e34e991678fd3a’
2022-04-29T06:46:57.5130426Z exists in the repository.
2022-04-29T06:46:57.5131359Z Error from Octopus Server (HTTP 404 NotFound)
2022-04-29T06:46:57.5131644Z Exit code: -7

I have tried this also without the commit, just with the gitRef. I have also tried removing ref/ from the start of the ref. All of these produced the same errors.

Hi Leslie,

Thanks for the additional info.

Just to clarify, does the gitRef refs/pull/34522/merge and commit f30f2ec61693ba755777984b16e34e991678fd3a refer to the deployment_process.ocl file or are they referring to the package(s) being built?

I’m unsure if this would fit your use case, but if you’re wanting to use the latest version of the deployment process you can simply specify the desired branch within the --gitRef e.g.

octo create-release --server=https://xxxx --apikey=API-xxxxx --space=<spaceName> --project=CaC --gitref=main


those refer to the commit that the pull request generated for purposes of running a build. they refer to both the ocl and the packages being built, since both can be changed in the PR. That is one answer I have thought of, is to use the ref from the source of the PR, not the generated ephemeral commit.

Is there a way via octo.exe to discover if a project is using Config as Code? The challenge there is that I now have to detect that and then use --gitRef and --gitCommit with octo.exe. It would be nice if I could just pass those and octo.exe would send them on as needed. The scenario is that we have scripts that run for all build pipelines and will need to interact with both Config as Code enabled octopus projects as well as ones that are not using Config as Code.

Hey @lbrody,

That is a great question. I will pass this along to our engineering team to weigh in on as this might be a feature they would consider including in the future. In the meantime, your best option would likely be to add a script step in your pipeline and use an API call to determine if the project is using version control and then proceed as desired based on the result.

I hope that helps, we’ll keep you updated with any news from engineering.


thanks @brent_kinney , that was what I was thinking I would need to do, thanks for confirming. Is the best way to verify via the API to see if the links in a project includes the ‘Branches’ key, or is there a better way?

so assuming that $project is returned from a GET to /api/projects/project-1234 doing something like this in PowerShell

if ($project.Links.Branches) {
        # Config as Code is configured

Hey @lbrody,

I think you’ll want to use "IsVersionControlled": true
Here’s an example of a project that has version control enabled.

  "Id": "Projects-21",
  "SpaceId": "Spaces-1",
  "VariableSetId": "variableset-Projects-21",
  "DeploymentProcessId": "deploymentprocess-Projects-21",
  "ClonedFromProjectId": null,
  "DiscreteChannelRelease": false,
  "IncludedLibraryVariableSetIds": [
  "DefaultToSkipIfAlreadyInstalled": false,
  "TenantedDeploymentMode": "TenantedOrUntenanted",
  "DefaultGuidedFailureMode": "EnvironmentDefault",
  "VersioningStrategy": null,
  "ReleaseCreationStrategy": {
    "ChannelId": null,
    "ReleaseCreationPackage": null,
    "ReleaseCreationPackageStepId": null
  "Templates": [
      "Id": "c6f614c1-e266-4cf0-8f1e-b703d3f1eaf8",
      "Name": "Test",
      "Label": "",
      "HelpText": null,
      "DefaultValue": "Test",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
  "AutoDeployReleaseOverrides": [],
  "ReleaseNotesTemplate": null,
  "DeploymentChangesTemplate": null,
  "ExtensionSettings": [],
  "Name": "Support Onboarding App",
  "Slug": "support-onboarding-app",
  "Description": "",
  "IsDisabled": false,
  "ProjectGroupId": "ProjectGroups-1",
  "LifecycleId": "Lifecycles-3",
  "AutoCreateRelease": false,
  "IsVersionControlled": true,
  "PersistenceSettings": {
    "Type": "VersionControlled",
    "Url": "",
    "Credentials": {
      "Type": "Reference",
      "Id": "GitCredentials-1"
    "DefaultBranch": "main",
    "BasePath": ".octopus/SupportOnboarding"
  "ProjectConnectivityPolicy": {
    "SkipMachineBehavior": "None",
    "TargetRoles": [],
    "AllowDeploymentsToNoTargets": false,
    "ExcludeUnhealthyTargets": false
  "Links": {
    "Self": "/api/Spaces-1/projects/Projects-21/{gitRef}",
    "Variables": "/api/Spaces-1/variables/variableset-Projects-21",
    "Releases": "/api/Spaces-1/projects/Projects-21/releases{/version}{?skip,take,searchByVersion}",
    "Channels": "/api/Spaces-1/projects/Projects-21/channels{/id}{?skip,take,partialName}",
    "Triggers": "/api/Spaces-1/projects/Projects-21/triggers{?skip,take,partialName,triggerActionType,triggerActionCategory,runbooks}",
    "ScheduledTriggers": "/api/Spaces-1/projects/Projects-21/triggers/scheduled{?skip,take,partialName,ids}",
    "OrderChannels": "/api/Spaces-1/projects/Projects-21/channels/order",
    "Progression": "/api/Spaces-1/projects/Projects-21/progression{?aggregate}",
    "RunbookTaskRunDashboardItemsTemplate": "/api/Spaces-1/progression/runbooks/taskRuns{?skip,take,ids,projectIds,runbookIds,environmentIds,tenantIds,taskIds}",
    "DeploymentProcess": "/api/Spaces-1/projects/Projects-21/{gitRef}/deploymentprocesses",
    "DeploymentSettings": "/api/Spaces-1/projects/Projects-21/{gitRef}/deploymentsettings",
    "Web": "/app#/Spaces-1/projects/Projects-21",
    "Logo": "/api/Spaces-1/projects/Projects-21/logo?cb=2022.1.2495",
    "Metadata": "/api/Spaces-1/projects/Projects-21/metadata",
    "Runbooks": "/api/Spaces-1/projects/Projects-21/runbooks{?skip,take,partialName}",
    "RunbookSnapshots": "/api/Spaces-1/projects/Projects-21/runbookSnapshots{/name}{?skip,take,searchByName}",
    "Summary": "/api/Spaces-1/projects/Projects-21/{gitRef}/summary",
    "GitConnectionTest": "/api/Spaces-1/projects/Projects-21/git/connectivity-test",
    "Branches": "/api/Spaces-1/projects/Projects-21/git/branches{/name}{?skip,take,searchByName,refresh}",
    "RepositoryModified": "/api/Spaces-1/projects/Projects-21/git/modified",
    "ValidateGitRef": "/api/Spaces-1/projects/Projects-21/{gitRef}/validate"

You can see about halfway down is the IsVersionControlled setting.


awesome, that is what I was looking for. feel free to close the case

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.