File tree Expand file tree Collapse file tree 6 files changed +50
-9
lines changed
Expand file tree Collapse file tree 6 files changed +50
-9
lines changed Original file line number Diff line number Diff line change 3333 - run :
3434 name : Assert environment variables have been set
3535 command : |
36+ if [ $CLOUDSMITH_ORGANISATION != "financial-times" ]
37+ then
38+ echo "Test failed: CLOUDSMITH_ORGANISATION has not been set correctly."
39+ exit 1
40+ fi
3641 if [ $CLOUDSMITH_SERVICE_IDENTIFIER != "circleci-orb-testing" ]
3742 then
3843 echo "Test failed: CLOUDSMITH_SERVICE_IDENTIFIER has not been set."
5661 - run :
5762 name : Assert environment variables have been set
5863 command : |
64+ if [ $CLOUDSMITH_DOWNLOADS_DOMAIN != "packages.ft.com" ]
65+ then
66+ echo "Test failed: CLOUDSMITH_DOWNLOADS_DOMAIN has not been set correctly."
67+ exit 1
68+ fi
5969 if [ -z $CLOUDSMITH_PIP_INDEX_URL ]
6070 then
6171 echo "Test failed: CLOUDSMITH_PIP_INDEX_URL has not been set."
Original file line number Diff line number Diff line change @@ -9,9 +9,16 @@ parameters:
99 type : string
1010steps :
1111 - run :
12- name : Prepare script parameters
12+ name : Configure Cloudsmith organisation
1313 command : |
14- echo "export CLOUDSMITH_SERVICE_IDENTIFIER=\"<<parameters.service_identifier>>\"" >> $BASH_ENV
14+ if [ -z "$CLOUDSMITH_ORGANISATION" ]
15+ then
16+ echo "export CLOUDSMITH_ORGANISATION=\"financial-times\"" >> "$BASH_ENV"
17+ fi
1518 - run :
16- name : Authenticate with OIDC and generate a temporary OIDC token
19+ name : Configure Cloudsmith service account
20+ command : |
21+ echo "export CLOUDSMITH_SERVICE_IDENTIFIER=\"<<parameters.service_identifier>>\"" >> "$BASH_ENV"
22+ - run :
23+ name : Authenticate with OIDC
1724 command : <<include(scripts/authenticate_with_oidc.sh)>>
Original file line number Diff line number Diff line change @@ -11,9 +11,13 @@ steps:
1111 - authenticate_with_oidc :
1212 service_identifier : <<parameters.service_identifier>>
1313 - run :
14- name : Prepare script parameters
14+ name : Configure Cloudsmith domains
15+ command : <<include(scripts/configure_cloudsmith_domains.sh)>>
16+ - run :
17+ name : Configure Cloudsmith repository
1518 command : |
1619 echo "export CLOUDSMITH_REPOSITORY_IDENTIFIER=\"<<parameters.repository_identifier>>\"" >> $BASH_ENV
20+ echo "CLOUDSMITH_REPOSITORY_IDENTIFIER=<<parameters.repository_identifier>>"
1721 - run :
1822 name : Set environment variables for pip
1923 command : <<include(scripts/set_env_vars_for_pip.sh)>>
Original file line number Diff line number Diff line change 55
66set +e
77
8+ if [ -z " $CLOUDSMITH_ORGANISATION " ]
9+ then
10+ echo " Unable to generate OIDC token. Environment variable CLOUDSMITH_ORGANISATION is not set."
11+ exit 1
12+ fi
13+
814if [ -z " $CLOUDSMITH_SERVICE_IDENTIFIER " ]
915then
1016 echo " Unable to generate OIDC token. Environment variable CLOUDSMITH_SERVICE_IDENTIFIER is not set."
1117 exit 1
1218fi
1319
14- echo " Generating Cloudsmith OIDC token for service account: $CLOUDSMITH_SERVICE_IDENTIFIER "
20+ echo " Generating Cloudsmith OIDC token for service account: $CLOUDSMITH_ORGANISATION / $ CLOUDSMITH_SERVICE_IDENTIFIER"
1521
1622RESPONSE=$( curl -X POST -H " Content-Type: application/json" \
1723 -d " {\" oidc_token\" :\" $CIRCLE_OIDC_TOKEN_V2 \" , \" service_slug\" :\" $CLOUDSMITH_SERVICE_IDENTIFIER \" }" \
18- --silent --show-error " https://api.cloudsmith.io/openid/financial-times /" )
24+ --silent --show-error " https://api.cloudsmith.io/openid/$CLOUDSMITH_ORGANISATION /" )
1925
2026CLOUDSMITH_OIDC_TOKEN=$( echo " $RESPONSE " | grep -o ' "token": "[^"]*' | grep -o ' [^"]*$' )
2127
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ if [ -z " $CLOUDSMITH_DOWNLOADS_DOMAIN " ]
4+ then
5+ echo " export CLOUDSMITH_DOWNLOADS_DOMAIN=\" packages.ft.com\" " >> " $BASH_ENV "
6+ fi
7+
Original file line number Diff line number Diff line change 77
88if [ -z " $CLOUDSMITH_SERVICE_IDENTIFIER " ] || [ -z " $CLOUDSMITH_OIDC_TOKEN " ]
99then
10- echo " Unable to find an OIDC token to use. Please ensure the authenticate-with-oidc command has been run before this command."
10+ echo " Unable to find an OIDC token to use. Please ensure the authenticate_with_oidc command has been run before this command."
1111 exit 1
1212fi
1313
1717 exit 1
1818fi
1919
20- CLOUDSMITH_PIP_INDEX_URL=" https://$CLOUDSMITH_SERVICE_IDENTIFIER :$CLOUDSMITH_OIDC_TOKEN @packages.ft.com/basic/$CLOUDSMITH_REPOSITORY_IDENTIFIER /python/simple/"
20+ if [ -z " $CLOUDSMITH_DOWNLOADS_DOMAIN " ]
21+ then
22+ echo " Unable to set environment variables for pip. Env var CLOUDSMITH_DOWNLOADS_DOMAIN is not defined."
23+ exit 1
24+ fi
25+
26+
27+ CLOUDSMITH_PIP_INDEX_URL=" https://$CLOUDSMITH_SERVICE_IDENTIFIER :$CLOUDSMITH_OIDC_TOKEN @$CLOUDSMITH_DOWNLOADS_DOMAIN /basic/$CLOUDSMITH_REPOSITORY_IDENTIFIER /python/simple/"
2128
2229echo " export CLOUDSMITH_PIP_INDEX_URL=\" $CLOUDSMITH_PIP_INDEX_URL \" " >> " $BASH_ENV "
2330
2431echo " The following environment variables have been exported. Note, the OIDC token has been masked below."
2532echo " "
26- echo " CLOUDSMITH_PIP_INDEX_URL=https://$CLOUDSMITH_SERVICE_IDENTIFIER :********@packages.ft.com /basic/$CLOUDSMITH_REPOSITORY_IDENTIFIER /python/simple/"
33+ echo " CLOUDSMITH_PIP_INDEX_URL=https://$CLOUDSMITH_SERVICE_IDENTIFIER :********@$CLOUDSMITH_DOWNLOADS_DOMAIN /basic/$CLOUDSMITH_REPOSITORY_IDENTIFIER /python/simple/"
You can’t perform that action at this time.
0 commit comments