mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-14 11:08:06 +00:00
Updated deploy-onefuzz-via-azure-devops (#233)
This commit is contained in:
@ -9,18 +9,20 @@
|
|||||||
# to deploy OneFuzz on Azure.
|
# to deploy OneFuzz on Azure.
|
||||||
#
|
#
|
||||||
# List of custom variables:
|
# List of custom variables:
|
||||||
# | Variable Name | Comments |
|
# | Variable Name | Comments | Required/Optional |
|
||||||
# |----------------------|-----------------------------------------------------------|
|
# |----------------------|-----------------------------------------------------------|-------------------|
|
||||||
# |AZURE_CLIENT_ID | The appication ID created by you or the deployment script |
|
# |AZURE_CLIENT_ID | The appication ID created by you or the deployment script | Required |
|
||||||
# |AZURE_CLIENT_SECRET | Secret created by App registration process |
|
# |AZURE_CLIENT_SECRET | Secret created by App registration process | Required |
|
||||||
# |AZURE_TENANT_ID | Tenant ID of the Azure Subscription |
|
# |AZURE_TENANT_ID | Tenant ID of the Azure Subscription | Required |
|
||||||
# |CONTACT_EMAIL_ADDRESS | Email address for communication |
|
# |CONTACT_EMAIL_ADDRESS | Email address for communication | Required |
|
||||||
# |ONEFUZZ_DEPLOY_LOC | Deployment Folder location of this script location |
|
# |DEPLOY_ARGS | Specify OneFuzz deploy.py arguments | Optional |
|
||||||
# |ONEFUZZ_INSTANCE_NAME | Instance name of Onefuzz Deployement |
|
# |ONEFUZZ_DEPLOY_LOC | Deployment Folder location of this script location | Required |
|
||||||
# |ONEFUZZ_SERVICE_URL | OneFuzz service URL. Generally the url defined in App |
|
# |ONEFUZZ_INSTANCE_NAME | Instance name of Onefuzz Deployement | Required |
|
||||||
# | | Registration |
|
# |ONEFUZZ_SERVICE_URL | OneFuzz service URL. Generally the url defined in App | Required |
|
||||||
# |REGION | OneFuzz Region (prefer westus2) |
|
# | | Registration | Required |
|
||||||
# |RESOURCE_GROUP_NAME | Resource gorup name for OneFuzz deployment |
|
# |REGION | OneFuzz Region (prefer westus2) | Required |
|
||||||
|
# |RESOURCE_GROUP_NAME | Resource group name for OneFuzz deployment | Required |
|
||||||
|
# |VERSION | Specify OneFuzz version, defaults to latest | Optional |
|
||||||
#
|
#
|
||||||
# Note: Make sure to provide the App owners permission to onefuzz resource group
|
# Note: Make sure to provide the App owners permission to onefuzz resource group
|
||||||
|
|
||||||
@ -48,8 +50,14 @@ stages:
|
|||||||
python -m pip install pipenv tox
|
python -m pip install pipenv tox
|
||||||
pipenv install
|
pipenv install
|
||||||
artifact="artifact"
|
artifact="artifact"
|
||||||
pipenv run python get_latest_version.py -path $artifact
|
if [ -z $(VERSION) ]
|
||||||
version="$(pipenv run python get_latest_version.py -version)"
|
then
|
||||||
|
pipenv run python get_latest_version.py -path $artifact
|
||||||
|
version="$(pipenv run python get_latest_version.py -display_latest_version)"
|
||||||
|
else
|
||||||
|
pipenv run python get_latest_version.py -path $artifact -version $(VERSION)
|
||||||
|
version="$(VERSION)"
|
||||||
|
fi
|
||||||
echo "Onefuzz version is $version"
|
echo "Onefuzz version is $version"
|
||||||
echo "##vso[task.setvariable variable=version;isOutput=true]$version"
|
echo "##vso[task.setvariable variable=version;isOutput=true]$version"
|
||||||
echo "##vso[task.setvariable variable=artifact]$artifact"
|
echo "##vso[task.setvariable variable=artifact]$artifact"
|
||||||
@ -74,7 +82,7 @@ stages:
|
|||||||
script: |
|
script: |
|
||||||
set -ex
|
set -ex
|
||||||
az login --service-principal -u $(ONEFUZZ_SERVICE_URL) -p $(AZURE_CLIENT_SECRET) --tenant $(AZURE_TENANT_ID)
|
az login --service-principal -u $(ONEFUZZ_SERVICE_URL) -p $(AZURE_CLIENT_SECRET) --tenant $(AZURE_TENANT_ID)
|
||||||
python deploy.py --client_id $(AZURE_CLIENT_ID) --client_secret $(AZURE_CLIENT_SECRET) $REGION $RESOURCE_GROUP_NAME $ONEFUZZ_INSTANCE_NAME $CONTACT_EMAIL_ADDRESS
|
python deploy.py --client_id $(AZURE_CLIENT_ID) --client_secret $(AZURE_CLIENT_SECRET) $REGION $RESOURCE_GROUP_NAME $ONEFUZZ_INSTANCE_NAME $CONTACT_EMAIL_ADDRESS $DEPLOY_ARGS
|
||||||
echo "Deployed Onefuzz $(onefuzz_release.version)"
|
echo "Deployed Onefuzz $(onefuzz_release.version)"
|
||||||
|
|
||||||
- task: CopyFiles@2
|
- task: CopyFiles@2
|
||||||
|
@ -11,9 +11,16 @@ BASE_URL = "https://api.github.com/repos/microsoft/onefuzz"
|
|||||||
|
|
||||||
|
|
||||||
class Onefuzz:
|
class Onefuzz:
|
||||||
def get_latest_version(self):
|
def get_latest_version_name(self):
|
||||||
latest_releasee = requests.get(f"{BASE_URL}/releases/latest").json()
|
latest_release = requests.get(f"{BASE_URL}/releases/latest").json()
|
||||||
return (latest_releasee["id"], latest_releasee["name"])
|
return latest_release["name"]
|
||||||
|
|
||||||
|
def get_release_id_by_name(self, version_name=None):
|
||||||
|
if version_name is None:
|
||||||
|
release = requests.get(f"{BASE_URL}/releases/latest").json()
|
||||||
|
else:
|
||||||
|
release = requests.get(f"{BASE_URL}/releases/tags/{version_name}").json()
|
||||||
|
return release["id"]
|
||||||
|
|
||||||
def list_assets(self, release_id):
|
def list_assets(self, release_id):
|
||||||
assets = requests.get(f"{BASE_URL}/releases/{release_id}/assets").json()
|
assets = requests.get(f"{BASE_URL}/releases/{release_id}/assets").json()
|
||||||
@ -34,8 +41,8 @@ class Onefuzz:
|
|||||||
for artifact in artifacts:
|
for artifact in artifacts:
|
||||||
self.download_artifact(path, artifact["id"], artifact["name"])
|
self.download_artifact(path, artifact["id"], artifact["name"])
|
||||||
|
|
||||||
def onefuzz_release_artifacts(self, path):
|
def onefuzz_release_artifacts(self, path, version):
|
||||||
release_id, _ = self.get_latest_version()
|
release_id = self.get_release_id_by_name(version)
|
||||||
artifacts = self.list_assets(release_id)
|
artifacts = self.list_assets(release_id)
|
||||||
self.download_artifacts(path, artifacts)
|
self.download_artifacts(path, artifacts)
|
||||||
|
|
||||||
@ -55,16 +62,22 @@ def main():
|
|||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-version",
|
"-version",
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help="Get specific Onefuzz version",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-display_latest_version",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Get Onefuzz latest version",
|
help="Get Onefuzz latest version",
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.path:
|
if args.path:
|
||||||
Onefuzz().onefuzz_release_artifacts(args.path)
|
Onefuzz().onefuzz_release_artifacts(args.path, args.version)
|
||||||
|
|
||||||
if args.version:
|
if args.display_latest_version:
|
||||||
print(Onefuzz().get_latest_version()[1])
|
print(Onefuzz().get_latest_version_name())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user