Maybe a silly question, but how can I get the late...
# pact-broker
r
Maybe a silly question, but how can I get the latest version of a contract deployed to an environment? Similar to
describe-version --latest=production
except using environments
m
I think you can hit the APIs directly. If you query by environment, you can navigate to the deployed versions in that environment via the HAL relations
eventually you’ll get the resource that gives you this:
Copy code
curl -H"Authorization: Bearer ${PACT_BROKER_TOKEN}" <https://testdemo.pactflow.io/environments/47158b1e-a5e0-4198-a9ab-008aa5e18bc5/deployed-versions/currently-deployed> | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21165  100 21165    0     0  52388      0 --:--:-- --:--:-- --:--:-- 52388
{
  "_embedded": {
    "deployedVersions": [
      {
        "uuid": "838dc2d8-8554-4ca2-805e-464a6bfb5c5f",
        "currentlyDeployed": true,
        "createdAt": "2022-02-01T03:40:46+00:00",
        "_embedded": {
          "pacticipant": {
            "name": "pactflow-example-provider-js-sns",
            "_links": {
              "self": {
                "href": "<https://testdemo.pactflow.io/pacticipants/pactflow-example-provider-js-sns>"
              }
            }
          },
          "version": {
            "number": "d29ce65231c0c9a7cd857ba63503f1fc281eb4c3",
            "_links": {
              "self": {
                "title": "Version",
                "name": "d29ce65231c0c9a7cd857ba63503f1fc281eb4c3",
                "href": "<https://testdemo.pactflow.io/pacticipants/pactflow-example-provider-js-sns/versions/d29ce65231c0c9a7cd857ba63503f1fc281eb4c3>"
              }
            }
          },
          "environment": {
            "uuid": "47158b1e-a5e0-4198-a9ab-008aa5e18bc5",
            "name": "production",
            "displayName": "Production",
            "production": true,
            "createdAt": "2021-07-08T02:49:05+00:00",
            "_links": {
              "self": {
                "title": "Environment",
                "name": "production",
                "href": "<https://testdemo.pactflow.io/environments/47158b1e-a5e0-4198-a9ab-008aa5e18bc5>"
              },
              "pb:currently-deployed-deployed-versions": {
                "title": "Versions currently deployed to Production environment",
                "href": "<https://testdemo.pactflow.io/environments/47158b1e-a5e0-4198-a9ab-008aa5e18bc5/deployed-versions/currently-deployed>"
              },
              "pb:currently-supported-released-versions": {
                "title": "Versions released and supported in Production environment",
                "href": "<https://testdemo.pactflow.io/environments/47158b1e-a5e0-4198-a9ab-008aa5e18bc5/released-versions/currently-supported>"
              },
              "pb:environments": {
                "title": "Environments",
                "href": "<https://testdemo.pactflow.io/environments>"
              }
            }
          }
        },
        "_links": {
          "self": {
            "href": "<https://testdemo.pactflow.io/deployed-versions/838dc2d8-8554-4ca2-805e-464a6bfb5c5f>"
          }
        }
      },
...
You can see the version of
d29ce65231c0c9a7cd857ba63503f1fc281eb4c3
for the consumer deployed to prod
r
Yep, I see it. Thanks a lot for the answer, @Matt (pactflow.io / pact-js / pact-go)! What do you think about extending
describe-version
to return this information? Or maybe adding a new
describe-deployed
/`describe-released` that returns all the deployed/released versions on the environment, optionally filtering by name?
Copy code
pact-broker describe-deployed --environment=production --pacticipant="My Consumer"
👍 1
m
Make sense, I’d suggest raising a request at pact.canny.io (if it doesn’t exist already) and it can get prioritised there. If you can also attach the use case/justification that would help!
🙌 1
r