From 370548dc7276c9c09106353c89f254452daccedf Mon Sep 17 00:00:00 2001 From: Thomas Carpentier Date: Tue, 30 Jan 2024 11:35:38 +0100 Subject: [PATCH] Add new parameter gmsaas_version Force default value for gmsaas 1.9.0 --- bitrise.yml | 3 ++- main.go | 30 ++++++++++++++++++++++-------- step.yml | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/bitrise.yml b/bitrise.yml index a8bb45a..2bedcdd 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -5,7 +5,7 @@ app: envs: # If you want to share this step into a StepLib - BITRISE_STEP_ID: genymotion-saas-install-gmsaas-cli - - BITRISE_STEP_VERSION: "0.0.1" + - BITRISE_STEP_VERSION: "0.0.2" - BITRISE_STEP_GIT_CLONE_URL: https://github.com/genymobile/bitrise-step-genymotion-saas-install-gmsaas-cli.git - MY_STEPLIB_REPO_FORK_GIT_URL: $MY_STEPLIB_REPO_FORK_GIT_URL # Define these in your .bitrise.secrets.yml @@ -39,6 +39,7 @@ workflows: title: Genymotion SaaS - Install gmsaas run_if: "true" inputs: + - gmsaas_version: "1.9.0" - email: $GMCLOUD_SAAS_EMAIL - password: $GMCLOUD_SAAS_PASSWORD - script: diff --git a/main.go b/main.go index 494f600..2230aca 100644 --- a/main.go +++ b/main.go @@ -18,20 +18,34 @@ var isError bool = false type Config struct { GMCloudSaaSEmail string `env:"email,required"` GMCloudSaaSPassword stepconf.Secret `env:"password,required"` + GMCloudSaaSGmsaasVersion string `env:"gmsaas_version"` } // install gmsaas if not installed. -func ensureGMSAASisInstalled() error { +func ensureGMSAASisInstalled(version string) error { path, err := exec.LookPath("gmsaas") if err != nil { - log.Infof("Installing gmsaas ...") - cmd := command.New("pip3", "install", "gmsaas") - if out, err := cmd.RunAndReturnTrimmedCombinedOutput(); err != nil { - return fmt.Errorf("%s failed, error: %s | output: %s", cmd.PrintableCommandArgs(), err, out) + log.Infof("Installing gmsaas...") + + var installCmd *exec.Cmd + if version != "" { + installCmd = exec.Command("pip3", "install", "gmsaas=="+version) + } else { + installCmd = exec.Command("pip3", "install", "gmsaas") + } + + if out, err := installCmd.CombinedOutput(); err != nil { + return fmt.Errorf("%s failed, error: %s | output: %s", installCmd.Args, err, out) } - log.Infof("gmsaas has been installed.") + + if version != "" { + log.Infof("gmsaas %s has been installed.", version) + } else { + log.Infof("gmsaas has been installed.") + } + } else { - log.Infof("gmsaas is already installed : %s", path) + log.Infof("gmsaas is already installed: %s", path) } // Set Custom user agent to improve customer support @@ -92,7 +106,7 @@ func main() { } stepconf.Print(c) - if err := ensureGMSAASisInstalled(); err != nil { + if err := ensureGMSAASisInstalled(c.GMCloudSaaSGmsaasVersion); err != nil { abortf("%s", err) } configureAndroidSDKPath() diff --git a/step.yml b/step.yml index 808cb28..cb9d777 100644 --- a/step.yml +++ b/step.yml @@ -13,9 +13,9 @@ summary: | Install gmsaas, command line interface to rule all your virtual devices hosted in Genymotion SaaS solution. description: | This step installs gmsaas cli, it allaows user to rule all your virtual devices hosted in Genymotion SaaS solution without opening an Internet browser. -website: https://github.com/thomascarpentier/bitrise-step-genymotion-saas-install-gmsaas-cli -source_code_url: https://github.com/thomascarpentier/bitrise-step-genymotion-saas-install-gmsaas-cli -support_url: https://github.com/thomascarpentier/bitrise-step-genymotion-saas-install-gmsaas-cli/issues +website: https://github.com/genymobile/bitrise-step-genymotion-saas-install-gmsaas-cli +source_code_url: https://github.com/genymobile/bitrise-step-genymotion-saas-install-gmsaas-cli +support_url: https://github.com/genymobile/bitrise-step-genymotion-saas-install-gmsaas-cli/issues host_os_tags: - osx-10.10 - ubuntu-16.04 @@ -78,5 +78,13 @@ inputs: summary: "" description: |- Password of your Genymotion Cloud SaaS account. - is_required: true is_sensitive: true + is_required: true + + - gmsaas_version: "1.9.0" + opts: + title: gmsaas version + summary: "" + description: |- + Install a specific version of gmsaas, per default it will install the latest gmsaas compatible : 1.9.0 +