From 5f58796d4373349fede39f700bb6ce2cc0f5f2d5 Mon Sep 17 00:00:00 2001 From: Michael Grondines Date: Thu, 7 Jan 2021 14:24:34 -0500 Subject: [PATCH 1/3] Added Jenkins config Added Jenkins and deployment package configuration SNOW-494 --- .deployment.config | 42 ++++++++++++++++++++++++++++++ Jenkinsfile | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .deployment.config create mode 100644 Jenkinsfile diff --git a/.deployment.config b/.deployment.config new file mode 100644 index 00000000..24db8d14 --- /dev/null +++ b/.deployment.config @@ -0,0 +1,42 @@ +{ + "team_name": "searchuiextensions", + "product": "search-ui-extensions-cdn", + "general": { + "environments_order": { + "sequential": [ + "dev", + "qa", + "prd" + ] + }, + "start_environment_automatically": true + }, + "snyk": { + "org": "coveo-jsui", + "no_container_images": true + }, + "observatory": { + "no_endpoint": true + }, + "veracode": { + "no_scan": true + }, + "phases": { + "s3": { + "dev": { + "bucket": "coveo-ndev-binaries" + }, + "qa": { + "bucket": "coveo-nqa-binaries" + }, + "prd": { + "bucket": "coveo-nprod-binaries" + }, + "directory": "proda/StaticCDN", + "parameters": { + "acl": "public-read" + } + } + }, + "deployment_config_version": 1 +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..647e7423 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,64 @@ +library( + identifier: "jenkins-common-lib@v1.4", + retriever: modernSCM(github(credentialsId: "github-app-dev", repository: "jenkins-common-lib", repoOwner: "coveo")), + changelog: false +) + +pipeline { + agent { + label "linux && docker" + } + options { + timestamps() + ansiColor("xterm") + buildDiscarder(logRotator(numToKeepStr: "30")) + timeout(time: 1, unit: "HOURS") + } + environment { + NODE_IMAGE = "node:lts" + DEPLOY_PIPELINE_IMAGE = '458176070654.dkr.ecr.us-east-1.amazonaws.com/jenkins/deployment_package:v7' + } + + stages { + stage("Setup") { + steps { + withDockerContainer(image: NODE_IMAGE, args: "-u root:root") { + sh "npm install" + sh "npm run lint" + sh "npm run testCoverage" + sh "npm run dev & npx wait-on http://localhost:8080" + sh "npx cypress run" + } + } + } + + stage("Test package") { + steps { + withDockerContainer(image: NODE_IMAGE, args: "-u root:root") { + sh "node ./scripts/before.deploy.js" + } + + withCredentials([string(credentialsId: 'snyk_token', variable: 'SNYK_TOKEN')]) { + runSnyk(org: "coveo-jsui", directory: ".") + } + + withDockerContainer(image: DEPLOY_PIPELINE_IMAGE) { + sh "deployment-package package create --version ${params.NPM_PACKAGE_VERSION} --dry-run" + } + } + } + /* + stage("Deploy") { + steps { + + withDockerContainer(image: DEPLOY_PIPELINE_IMAGE) { + script { + packageName = sh (script: "deployment-package package create --version ${params.NPM_PACKAGE_VERSION}", returnStdout: true).trim() + sh "deployment-package package deploy --package-name ${packageName} --target-environment dev" + } + } + } + } + */ + } +} \ No newline at end of file From d9d1c7e5fbc1dd4ad59aeb06e7b2b2f3c7674220 Mon Sep 17 00:00:00 2001 From: Michael Grondines Date: Mon, 8 Mar 2021 16:25:40 -0500 Subject: [PATCH 2/3] Slight changes to the jenkinsfile SNOW-494 --- .prettierignore | 4 +++- Jenkinsfile | 47 +++++++++++++++++++++++------------------------ package-lock.json | 9 ++++++--- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/.prettierignore b/.prettierignore index 3b68bcd3..3ba216fe 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,4 +7,6 @@ node_modules/**/* .prettierignore .snyk .travis.yml -LICENSE \ No newline at end of file +LICENSE +Jenkinsfile +.deployment.config \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 647e7423..4b0dfc47 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ library( - identifier: "jenkins-common-lib@v1.4", + identifier: "jenkins-common-lib@v1.6", retriever: modernSCM(github(credentialsId: "github-app-dev", repository: "jenkins-common-lib", repoOwner: "coveo")), changelog: false ) @@ -20,45 +20,44 @@ pipeline { } stages { - stage("Setup") { + stage("Build") { steps { withDockerContainer(image: NODE_IMAGE, args: "-u root:root") { - sh "npm install" - sh "npm run lint" - sh "npm run testCoverage" - sh "npm run dev & npx wait-on http://localhost:8080" - sh "npx cypress run" + withCredentials([string(credentialsId: 'coveralls-search-ui-extensions', variable: 'COVERALLS_REPO_TOKEN')]) { + sh "apt-get update -qq" + sh "apt install -qq -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget" + sh "npm install" + sh "npm run lint" + sh "npm run build" + sh "npm run testCoverage" + } } } } stage("Test package") { steps { - withDockerContainer(image: NODE_IMAGE, args: "-u root:root") { - sh "node ./scripts/before.deploy.js" - } - withCredentials([string(credentialsId: 'snyk_token', variable: 'SNYK_TOKEN')]) { runSnyk(org: "coveo-jsui", directory: ".") } - - withDockerContainer(image: DEPLOY_PIPELINE_IMAGE) { - sh "deployment-package package create --version ${params.NPM_PACKAGE_VERSION} --dry-run" - } } } - /* - stage("Deploy") { + + stage("Deploy on Tag") { + when { + tag pattern: "^v\\d+\\.\\d+\\.\\d+$", comparator: "REGEXP" + } steps { - - withDockerContainer(image: DEPLOY_PIPELINE_IMAGE) { - script { - packageName = sh (script: "deployment-package package create --version ${params.NPM_PACKAGE_VERSION}", returnStdout: true).trim() - sh "deployment-package package deploy --package-name ${packageName} --target-environment dev" - } + sh "mkdir -p s3/${TAG_NAME}" + sh "cp -r bin/commonjs bin/css bin/es6 bin/img bin/typings s3/${TAG_NAME}" + + script { + deploymentPackage.command( + command: "package create", + parameters: [ withDeploy: true ] + ) } } } - */ } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a987aa86..082f1135 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4229,7 +4229,8 @@ }, "kind-of": { "version": "6.0.2", - "resolved": "", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true } } @@ -7103,7 +7104,8 @@ }, "kind-of": { "version": "6.0.2", - "resolved": "", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true } } @@ -12655,7 +12657,8 @@ }, "kind-of": { "version": "6.0.2", - "resolved": "", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true } } From f0a135b7875d473821f836236e1b7c6253f6a0f1 Mon Sep 17 00:00:00 2001 From: Michael Grondines Date: Mon, 8 Mar 2021 16:34:49 -0500 Subject: [PATCH 3/3] Damnation SNOW-494 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4b0dfc47..b17d7d78 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { stage("Deploy on Tag") { when { - tag pattern: "^v\\d+\\.\\d+\\.\\d+$", comparator: "REGEXP" + tag pattern: "^v\\d+\\.\\d+\\.\\d+", comparator: "REGEXP" } steps { sh "mkdir -p s3/${TAG_NAME}"