diff --git a/ansible/roles/offline-installer/defaults/main.yml b/ansible/roles/offline-installer/defaults/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..d71509fd05a834b747ccd12422dcedf6c8bc6ba1 --- /dev/null +++ b/ansible/roles/offline-installer/defaults/main.yml @@ -0,0 +1,2 @@ +--- +time: "YEAR-MONTH-DATE-HOUR-MINUTE-SECOND-INSTALLERTYPE" diff --git a/ansible/roles/offline-installer/tasks/main.yml b/ansible/roles/offline-installer/tasks/main.yml index cc64c39b22388db60451e3f0d77c9bcc0f3b7dbc..c24130f0417ad729933357cd581284cd85dd2424 100644 --- a/ansible/roles/offline-installer/tasks/main.yml +++ b/ansible/roles/offline-installer/tasks/main.yml @@ -1,4 +1,9 @@ --- +- name: get the date and time for the artifact + set_fact: + time: "{{ lookup('pipe', 'date +\"%Y-%b-%d-%H-%M-%S\"') }}-{{offline_installer_type}}" + when: uploadInstaller is not defined + - name: copy the env.json file to the repo template: src: "{{item}}.j2" @@ -17,11 +22,12 @@ - setupOfflineInstaller.sh - build.sh - envfile + - 32-bit-prerequisite.sh when: uploadInstaller is not defined - name: create a directory to store artifacts file: - path: "{{offline_repo_location}}/offline-installer-repo/offline_artifacts/{{build_number}}" + path: "{{offline_repo_location}}/offline-installer-repo/offline_artifacts/{{time}}" state: directory recurse: yes when: uploadInstaller is not defined diff --git a/ansible/roles/offline-installer/tasks/uploadToAzure.yml b/ansible/roles/offline-installer/tasks/uploadToAzure.yml index 737a44a94c2ea9d117361bd779fdbf6828f7bb3e..0e3323837da8999cc3f838d518e166e2afd01826 100644 --- a/ansible/roles/offline-installer/tasks/uploadToAzure.yml +++ b/ansible/roles/offline-installer/tasks/uploadToAzure.yml @@ -13,3 +13,18 @@ AZURE_STORAGE_KEY: "{{sunbird_offline_azure_storage_key}}" async: 60 poll: 10 + +- name: get the directory name + shell: "ls {{offline_repo_location}}/offline-installer-repo/offline_artifacts/" + register: folderName + +- debug: + msg: "{{folderName.stdout}}" + +- name: Create a zip of the folder to archieve the artifact + archive: + path: + - "{{offline_repo_location}}/offline-installer-repo/offline_artifacts/{{folderName.stdout}}" + dest: "{{offline_repo_location}}/{{offline_installer_type}}.zip" + format: zip + diff --git a/ansible/roles/offline-installer/templates/32-bit-prerequisite.sh.j2 b/ansible/roles/offline-installer/templates/32-bit-prerequisite.sh.j2 new file mode 100644 index 0000000000000000000000000000000000000000..cbfa755b0e7c2722009641abf4043b7ff3cd6215 --- /dev/null +++ b/ansible/roles/offline-installer/templates/32-bit-prerequisite.sh.j2 @@ -0,0 +1,7 @@ +#!/bin/bash + +#Build the offline installer +cd /private/src/ +rm -rf node_modules +npm install leveldown --verbose +npm run dist diff --git a/ansible/roles/offline-installer/templates/build.sh.j2 b/ansible/roles/offline-installer/templates/build.sh.j2 index cd623171561191ff85e709154448bf5c3742216e..be33e2a59127c3708896ecfba63c060aa7870943 100644 --- a/ansible/roles/offline-installer/templates/build.sh.j2 +++ b/ansible/roles/offline-installer/templates/build.sh.j2 @@ -5,7 +5,14 @@ echo "Offline Installer for Sunbird" # Build script set -eo pipefail +if [ "{{offline_installer_type}}" == "windows32" ]; +then + + docker run --rm -v ${PWD}:/private/ i386/node:8.16.2-stretch bash -x /private/32-bit-prerequisite.sh + +fi + #chmod +x setupOfflineInstaller.sh docker run --rm --env-file envfile --env ELECTRON_CACHE="/root/.cache/electron" --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" -v ${PWD}:/project electronuserland/builder:wine bash -x setupOfflineInstaller.sh -echo "Archieved 64 bit DIKSHA\ Setup\ 1.0.0.exe and DIKSHA_1.0.0_amd64.deb" +echo "Build the installer succesfully" diff --git a/ansible/roles/offline-installer/templates/setupOfflineInstaller.sh.j2 b/ansible/roles/offline-installer/templates/setupOfflineInstaller.sh.j2 index df891b0887494470441757ee1bef375cb806f31f..a7d0c718c01c6cd0be017a1d5454be53c72cc810 100644 --- a/ansible/roles/offline-installer/templates/setupOfflineInstaller.sh.j2 +++ b/ansible/roles/offline-installer/templates/setupOfflineInstaller.sh.j2 @@ -3,25 +3,26 @@ # Downgrade the node version npm install -g n n 8.16 +cd /project/src +if [ "{{offline_installer_type}}" != "windows32" ]; +then #Build the offline installer -cd src -npm install -npm run dist + npm install + npm run dist +fi if [ "{{offline_installer_type}}" == "windows32" ]; then - npm run dist-win32 - ls -lR - cp 'dist/1.0.0/win/ia32/DIKSHA Setup 1.0.0.exe' ../offline_artifacts/{{build_number}}/ +# npm run dist + npm run dist-win32 + cp '/project/src/dist/1.0.0/win/ia32/DIKSHA Setup 1.0.0.exe' ../offline_artifacts/{{time}}/ elif [ "{{offline_installer_type}}" == "windows64" ]; then npm run dist-win64 - ls -lR - cp 'dist/1.0.0/win/x64/DIKSHA Setup 1.0.0.exe' ../offline_artifacts/{{build_number}}/ + cp '/project/src/dist/1.0.0/win/x64/DIKSHA Setup 1.0.0.exe' ../offline_artifacts/{{time}}/ elif [ "{{offline_installer_type}}" == "debian" ]; then npm run dist-linux - ls -lR - cp dist/1.0.0/linux/x64/DIKSHA_1.0.0_amd64.deb ../offline_artifacts/{{build_number}}/ + cp '/project/src/dist/1.0.0/linux/x64/DIKSHA_1.0.0_amd64.deb' ../offline_artifacts/{{time}}/ fi diff --git a/pipelines/offlineinstaller/Jenkinsfile b/pipelines/offlineinstaller/Jenkinsfile index 92edb28068a89319442ca62a4cb0368976d159b1..c24ee78c228b2b0258d9f7e105e26cc4c6e519aa 100644 --- a/pipelines/offlineinstaller/Jenkinsfile +++ b/pipelines/offlineinstaller/Jenkinsfile @@ -23,7 +23,7 @@ node() { stage('Pre requisites for installer') { values = [:] ansiblePlaybook = "${currentWs}/ansible/offline-installer.yml --vault-password-file /var/lib/jenkins/secrets/vault-pass " - ansibleExtraArgs = " --extra-vars \"offline_repo_location=$currentWs build_number=$BUILD_NUMBER offline_installer_type=${offline_installer_type}\" -vv" + ansibleExtraArgs = " --extra-vars \"offline_repo_location=$currentWs offline_installer_type=${offline_installer_type}\" -vv" values.put('currentWs', currentWs) values.put('env', envDir) values.put('module', module) @@ -42,7 +42,7 @@ node() { } values = [:] ansiblePlaybook = "${currentWs}/ansible/offline-installer.yml --vault-password-file /var/lib/jenkins/secrets/vault-pass " - ansibleExtraArgs = " --extra-vars \"offline_repo_location=$currentWs build_number=$BUILD_NUMBER uploadInstaller=True offline_installer_type=${offline_installer_type}\"" + ansibleExtraArgs = " --extra-vars \"offline_repo_location=$currentWs uploadInstaller=True offline_installer_type=${offline_installer_type}\"" values.put('currentWs', currentWs) values.put('env', envDir) values.put('module', module) @@ -51,12 +51,13 @@ node() { values.put('ansibleExtraArgs', ansibleExtraArgs) println values ansible_playbook_run(values) + archiveArtifacts artifacts: '*.zip', onlyIfSuccessful: true } } catch (err) { values = [:] ansiblePlaybook = "${currentWs}/ansible/offline-installer.yml --vault-password-file /var/lib/jenkins/secrets/vault-pass " - ansibleExtraArgs = " --extra-vars \"offline_repo_location=$currentWs removeOfflineInstallerFolder=True build_number=$BUILD_NUMBER offline_installer_type=${offline_installer_type}\"" + ansibleExtraArgs = " --extra-vars \"offline_repo_location=$currentWs removeOfflineInstallerFolder=True offline_installer_type=${offline_installer_type}\"" values.put('currentWs', currentWs) values.put('env', envDir) values.put('module', module)