From ff6d55163c13ba0cd764b209dc1252e2992cf2d8 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 15 Jun 2015 12:31:07 +0300 Subject: [PATCH] Add --maven parameter to add mvn commandline parameters Also adds a --teamcity flag, planned future functionality to add supplied jar dependencies to local maven repo, and flags for setting wildfly autodeployment parameters (url, user, password) Change-Id: I6690cda0d3bfd18d665ffbc61b8502f91f9fd475 --- scripts/BuildArchetypes.py | 16 +++++++++++++++- scripts/BuildDemos.py | 16 ++++++++++++---- scripts/BuildHelpers.py | 18 +++++++++--------- scripts/DeployHelpers.py | 23 +++++++++++++---------- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/scripts/BuildArchetypes.py b/scripts/BuildArchetypes.py index ffdbbe1c7a..82ebe85e43 100644 --- a/scripts/BuildArchetypes.py +++ b/scripts/BuildArchetypes.py @@ -11,7 +11,7 @@ # import subprocess -from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir +from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir, parser from DeployHelpers import deployWar ## DEFAULT VARIABLES ## @@ -50,6 +50,8 @@ def generateArchetype(archetype): cmd.append("-DartifactId=%s" % (artifactId)) cmd.append("-Dversion=1.0-SNAPSHOT") cmd.append("-DinteractiveMode=false") + if hasattr(args, "maven") and args.maven is not None: + cmd.extends(args.maven.split(" ")) # Generate pom.xml print("Generating pom.xml for archetype %s" % (archetype)) @@ -60,6 +62,14 @@ def generateArchetype(archetype): ## DO THIS IF RUN AS A SCRIPT (not import) ## if __name__ == "__main__": + # Add command line arguments for staging repos + parser.add_argument("framework", type=int, help="Framework repo id (comvaadin-XXXX)", nargs='?') + parser.add_argument("archetype", type=int, help="Archetype repo id (comvaadin-XXXX)", nargs='?') + parser.add_argument("plugin", type=int, help="Maven Plugin repo id (comvaadin-XXXX)", nargs='?') + + archetypesFailed = False + + # Parse the arguments args = getArgs() for archetype in archetypes: try: @@ -73,7 +83,11 @@ if __name__ == "__main__": deployWar(war, "%s.war" % (archetype.split("-", 2)[2])) except Exception as e: print("War %s failed to deploy: %s" % (war, e)) + archetypesFailed = True except: print("Archetype %s build failed" % (archetype)) + archetypesFailed = True removeDir(artifactId) print("") + if archetypesFailed: + sys.exit(1) diff --git a/scripts/BuildDemos.py b/scripts/BuildDemos.py index 396863350d..6d8445b4d1 100644 --- a/scripts/BuildDemos.py +++ b/scripts/BuildDemos.py @@ -15,7 +15,7 @@ try: except: print("BuildDemos depends on gitpython. Install it with `pip install gitpython`") sys.exit(1) -from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir +from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs from DeployHelpers import deployWar # Validated demos. name -> git url @@ -23,7 +23,6 @@ demos = { "dashboard" : "https://github.com/vaadin/dashboard-demo.git", "parking" : "https://github.com/vaadin/parking-demo.git", "addressbook" : "https://github.com/vaadin/addressbook.git", - "confirmdialog" : "https://github.com/samie/Vaadin-ConfirmDialog.git", "grid-gwt" : "https://github.com/vaadin/grid-gwt.git" } @@ -31,6 +30,11 @@ def checkout(folder, url): Repo.clone_from(url, folder) if __name__ == "__main__": + if getArgs().teamcity: + print("Add dependency jars from TeamCity here") + + demosFailed = False + for demo in demos: print("Validating demo %s" % (demo)) try: @@ -43,8 +47,12 @@ if __name__ == "__main__": deployWar(war) except Exception as e: print("War %s failed to deploy: %s" % (war, e)) + demosFailed = True print("%s demo validation succeeded!" % (demo)) - except: - print("%s demo validation failed" % (demo)) + except Exception as e: + print("%s demo validation failed: %s" % (demo, e)) + demosFailed = True removeDir(demo) print("") + if demosFailed: + sys.exit(1) diff --git a/scripts/BuildHelpers.py b/scripts/BuildHelpers.py index 7349c9b367..534ce53441 100644 --- a/scripts/BuildHelpers.py +++ b/scripts/BuildHelpers.py @@ -27,21 +27,19 @@ elif not isdir(resultPath): args = None -# Parse command line arguments +# Default argument parser +parser = argparse.ArgumentParser(description="Automated staging validation") +parser.add_argument("version", type=str, help="Vaadin version to use") +parser.add_argument("--maven", help="Additional maven command line parameters", default=None) +parser.add_argument("--teamcity", help="Use vaadin jars provided by teamcity", action="store_const", const=True, default=False) + +# Parse command line arguments def parseArgs(): - # Command line arguments for this script - parser = argparse.ArgumentParser(description="Automated staging validation") - parser.add_argument("version", type=str, help="Vaadin version to use") - parser.add_argument("framework", type=int, help="Framework repo id (comvaadin-XXXX)", nargs='?') - parser.add_argument("archetype", type=int, help="Archetype repo id (comvaadin-XXXX)", nargs='?') - parser.add_argument("plugin", type=int, help="Maven Plugin repo id (comvaadin-XXXX)", nargs='?') - # If no args, give help if len(sys.argv) == 1: args = parser.parse_args(["-h"]) else: args = parser.parse_args() - return args # Function for determining the path for maven executable @@ -81,6 +79,8 @@ def mavenValidate(artifactId, mvnCmd = mavenCmd, logFile = sys.stdout, repoIds = cmd = [mvnCmd] if hasattr(repoIds, "version") and repoIds.version is not None: cmd.append("-Dvaadin.version=%s" % (repoIds.version)) + if hasattr(repoIds, "maven") and repoIds.maven is not None: + cmd.extend(repoIds.maven.split(" ")) cmd.extend(["clean", "package", "validate"]) print("executing: %s" % (" ".join(cmd))) subprocess.check_call(cmd, cwd=join(getcwd(), artifactId), stdout=logFile) diff --git a/scripts/DeployHelpers.py b/scripts/DeployHelpers.py index c12c38d293..e8e27b98b6 100644 --- a/scripts/DeployHelpers.py +++ b/scripts/DeployHelpers.py @@ -11,12 +11,11 @@ except Exception as e: sys.exit(1) from requests.auth import HTTPDigestAuth from os.path import join, expanduser, basename +from BuildHelpers import parser, getArgs -# .deploy-url in home folder -deployUrlFile = join(expanduser("~"), ".deploy-url") - -# .deploy-credentials in home folder -deployCredFile = join(expanduser("~"), ".deploy-credentials") +parser.add_argument("--deployUrl", help="Wildfly management URL") +parser.add_argument("--deployUser", help="Deployment user", default=None) +parser.add_argument("--deployPass", help="Deployment password", default=None) # Helper for handling the full deployment # name should end with .war @@ -50,7 +49,11 @@ def doDeploy(hash, name): # Helper for adding Content-Type to headers def doPostJson(**kwargs): - return requests.post(headers={"Content-Type" : "application/json"}, **kwargs) + r = requests.post(headers={"Content-Type" : "application/json"}, **kwargs) + # Wildfly gives code 500 when asking for a non-existent deployment + if r.status_code == requests.codes.ok or r.status_code == 500: + return r + r.raise_for_status() def doUploadWarFile(warFile): # Upload request, just see the outcome @@ -70,10 +73,10 @@ def removeDeployment(name): # Read credentials file and return a HTTPDigestAuth object def getAuth(): - (deployUser, deployPass) = open(deployCredFile).read().strip().split(",") - return HTTPDigestAuth(deployUser, deployPass) + args = getArgs() + return HTTPDigestAuth(args.deployUser, args.deployPass) # Read the deploy url file and return the url def getUrl(): - return open(deployUrlFile).read().strip() - + return getArgs().deployUrl + -- 2.39.5