From 921a5f1cc45fd2109cd5433e4d82642d16e63413 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 4 Dec 2023 23:03:52 +0700 Subject: [PATCH 01/12] automated builds --- .gitignore | 4 +- .vscode/settings.json | 3 +- gen_release.py | 66 +++++++++++++++++ platformio.ini | 151 ++++++++++++++++++++++++++++++++++++++- src/espmega_iot_core.cpp | 4 ++ src/user_code.hpp | 11 +-- 6 files changed, 229 insertions(+), 10 deletions(-) create mode 100644 gen_release.py diff --git a/.gitignore b/.gitignore index 5c228a4..a4a37ad 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ .vscode/ipch .vs/ .vscode/ -.vscode/settings.json \ No newline at end of file +.vscode/settings.json +firmware/ +release/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 2975662..ee32b37 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -73,5 +73,6 @@ "C_Cpp_Runner.useLeakSanitizer": false, "C_Cpp_Runner.showCompilationTime": false, "C_Cpp_Runner.useLinkTimeOptimization": false, - "C_Cpp_Runner.msvcSecureNoWarnings": false + "C_Cpp_Runner.msvcSecureNoWarnings": false, + "cmake.sourceDirectory": "D:/Git/iot-firmware/.pio/libdeps/full/Adafruit BusIO" } \ No newline at end of file diff --git a/gen_release.py b/gen_release.py new file mode 100644 index 0000000..ed453a7 --- /dev/null +++ b/gen_release.py @@ -0,0 +1,66 @@ +import os +import shutil +import subprocess +import sys +import platform +import subprocess +import os +import shutil +import subprocess +import sys +import platform + + +# Get the current directory +current_dir = os.path.dirname(os.path.abspath(__file__)) + +# Define the path to the firmware folder +firmware_folder = os.path.join(current_dir, 'firmware') + +# Define the path to the release folder +release_folder = os.path.join(current_dir, 'release') + +# Add the path to the PlatformIO executable to the system PATH +platformio_path = os.path.expanduser('~/.platformio/penv/Scripts') + +if os.path.exists(release_folder): + # If the release folder exists, delete it + shutil.rmtree(release_folder) +os.makedirs(release_folder) + +# Get the current Git branch name +git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip() + +# Build the PlatformIO project +if len(sys.argv) > 1: + # If arguments are supplied, build the environments that match the arguments + environments = sys.argv[1:] + for environment in environments: + subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment], cwd=current_dir) + + # Iterate over the subfolders in the firmware folder + for subfolder in os.listdir(firmware_folder): + subfolder_path = os.path.join(firmware_folder, subfolder) + + # Check if the subfolder matches the environment argument + if subfolder == environment: + # Check if the subfolder contains a firmware.bin file + firmware_file = os.path.join(subfolder_path, 'firmware.bin') + if os.path.isfile(firmware_file): + # Move the firmware.bin file to the release folder with the Git branch name appended + new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") + shutil.move(firmware_file, new_file_name) +else: + # If no argument is supplied, build all environments + subprocess.run([f'{platformio_path}/platformio.exe', 'run'], cwd=current_dir) + + # Iterate over the subfolders in the firmware folder + for subfolder in os.listdir(firmware_folder): + subfolder_path = os.path.join(firmware_folder, subfolder) + + # Check if the subfolder contains a firmware.bin file + firmware_file = os.path.join(subfolder_path, 'firmware.bin') + if os.path.isfile(firmware_file): + # Move the firmware.bin file to the release folder with the Git branch name appended + new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") + shutil.move(firmware_file, new_file_name) diff --git a/platformio.ini b/platformio.ini index 1995297..b32f365 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,7 +8,153 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:wt32-eth01] +[platformio] +build_dir = .\firmware + +[env:full] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_ANALOG_MODULE -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd_climate] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 + +[env:climate_webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd_webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:ir_climate_analog_webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_ANALOG_MODULE -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd_analog] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_ANALOG_MODULE +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:minimal] platform = espressif32 board = wt32-eth01 framework = arduino @@ -22,5 +168,4 @@ lib_deps = siwats/ESPMegaPROR3@^1.3.0 robtillaart/DHTNEW@^0.4.18 seithan/Easy Nextion Library@^1.0.6 robtillaart/FRAM_I2C@^0.6.1 - esphome/ESPAsyncWebServer-esphome@^3.1.0 -monitor_speed = 115200 \ No newline at end of file + esphome/ESPAsyncWebServer-esphome@^3.1.0 \ No newline at end of file diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index ddfcaf2..a20b559 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -1837,6 +1837,7 @@ void set_mqtt_useauth(bool use_auth) ESPMega_FRAM.write8(FRAM_ADDRESS_MQTT_USEAUTH, MQTT_USE_AUTH); } +#ifdef ENABLE_WEBUI void set_webui_username(String username) { username.toCharArray(WEBUI_USERNAME, 32); @@ -1848,6 +1849,7 @@ void set_webui_password(String password) password.toCharArray(WEBUI_PASSWORD, 32); ESPMega_FRAM.write(FRAM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); } +#endif /** * @brief Resets the device to factory default settings. @@ -1884,8 +1886,10 @@ void factory_reset() set_ip("192.168.0.10"); set_gw("192.168.0.1"); set_netmask("255.255.255.0"); + #ifdef ENABLE_WEBUI set_webui_username("admin"); set_webui_password("admin"); + #endif // Reboot #ifdef ENABLE_INTERNAL_LCD diff --git a/src/user_code.hpp b/src/user_code.hpp index fba970a..938316e 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -16,11 +16,12 @@ #define VIRTUAL_INTERRUPT_PRELOAD // Preload Virtual Interrupts buffer // Enable Software Module(s) -#define ENABLE_INTERNAL_LCD -#define ENABLE_IR_MODULE -#define ENABLE_CLIMATE_MODULE // Require IR Module -#define ENABLE_ANALOG_MODULE -#define ENABLE_WEBUI +// Deprecated. Use Build Flags instead. +// #define ENABLE_INTERNAL_LCD +// #define ENABLE_IR_MODULE +// #define ENABLE_CLIMATE_MODULE // Require IR Module +// #define ENABLE_ANALOG_MODULE +// #define ENABLE_WEBUI // IR Kit Configuration #define IR_RECIEVE_PIN 35 From fc04b190a47b2777875577cacec44a4cbc7df3a0 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 5 Dec 2023 19:46:48 +0700 Subject: [PATCH 02/12] Update gen_release.py --- gen_release.py | 57 +++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/gen_release.py b/gen_release.py index ed453a7..a759918 100644 --- a/gen_release.py +++ b/gen_release.py @@ -9,6 +9,7 @@ import shutil import subprocess import sys import platform +import re # Get the current directory @@ -30,37 +31,41 @@ os.makedirs(release_folder) # Get the current Git branch name git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip() +commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()[:10] -# Build the PlatformIO project +# If arguments are supplied, build the environments that match the arguments if len(sys.argv) > 1: - # If arguments are supplied, build the environments that match the arguments environments = sys.argv[1:] - for environment in environments: - subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment], cwd=current_dir) - - # Iterate over the subfolders in the firmware folder - for subfolder in os.listdir(firmware_folder): - subfolder_path = os.path.join(firmware_folder, subfolder) - - # Check if the subfolder matches the environment argument - if subfolder == environment: - # Check if the subfolder contains a firmware.bin file - firmware_file = os.path.join(subfolder_path, 'firmware.bin') - if os.path.isfile(firmware_file): - # Move the firmware.bin file to the release folder with the Git branch name appended - new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") - shutil.move(firmware_file, new_file_name) -else: - # If no argument is supplied, build all environments - subprocess.run([f'{platformio_path}/platformio.exe', 'run'], cwd=current_dir) +# If no argument are supplied, build all environments listed in platformio.ini +else: + environments = [] + with open(os.path.join(current_dir, 'platformio.ini')) as f: + + # Iterate over the lines in platformio.ini + for line in f.readlines(): + + # Check if the line contains the string "env:" + if '[env:' in line: + + # Extract the environment using regular expressions + environment = re.search(r'\[env:(.*?)\]', line).group(1) + + # Add the environment to the list of environments + environments.append(environment) + +for environment in environments: + subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,f'-DFW_VERSION={git_branch}_{environment}_{commit_hash}'], cwd=current_dir) + # Iterate over the subfolders in the firmware folder for subfolder in os.listdir(firmware_folder): subfolder_path = os.path.join(firmware_folder, subfolder) - # Check if the subfolder contains a firmware.bin file - firmware_file = os.path.join(subfolder_path, 'firmware.bin') - if os.path.isfile(firmware_file): - # Move the firmware.bin file to the release folder with the Git branch name appended - new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") - shutil.move(firmware_file, new_file_name) + # Check if the subfolder matches the environment argument + if subfolder == environment: + # Check if the subfolder contains a firmware.bin file + firmware_file = os.path.join(subfolder_path, 'firmware.bin') + if os.path.isfile(firmware_file): + # Move the firmware.bin file to the release folder with the Git branch name and commit hash appended + new_file_name = os.path.join(release_folder, f"{git_branch}_{subfolder}_{commit_hash}.bin") + shutil.move(firmware_file, new_file_name) \ No newline at end of file From c8ff21f522eb9260b8280b7bc060ca782c21d4dc Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 14:59:24 +0700 Subject: [PATCH 03/12] finalize builder --- gen_release.py | 31 ++++++++++++++++++++++++++++++- src/espmega_iot_core.cpp | 5 +++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gen_release.py b/gen_release.py index a759918..34587da 100644 --- a/gen_release.py +++ b/gen_release.py @@ -10,6 +10,8 @@ import subprocess import sys import platform import re +import configparser +from time import sleep as delay # Get the current directory @@ -54,8 +56,35 @@ else: # Add the environment to the list of environments environments.append(environment) +# Remove old platformio.ini file from firmware folder if it exists +if os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')): + os.remove(os.path.join(firmware_folder, 'platformio.ini')) + +# Copy the platformio.ini file to the firmware folder +shutil.copyfile(os.path.join(current_dir, 'platformio.ini'), os.path.join(firmware_folder, 'platformio.ini')) + +# Check that the file is copied correctly +if not os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')): + raise Exception('platformio.ini file not copied correctly') + +# Read the platformio.ini file +config = configparser.ConfigParser() +config.read(os.path.join(firmware_folder, 'platformio.ini')) + +# Add firmware version to build_flags in platformio.ini for environment in environments: - subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,f'-DFW_VERSION={git_branch}_{environment}_{commit_hash}'], cwd=current_dir) + if 'build_flags' not in config[f'env:{environment}']: + config[f'env:{environment}']['build_flags'] = f'-DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"' + else: + config[f'env:{environment}']['build_flags'] = config[f'env:{environment}']['build_flags'] + f' -DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"' + +# if argument is not supplied, build all environments listed in platformio.ini +if len(sys.argv) == 1: + subprocess.run([f'{platformio_path}/platformio.exe', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) + +for environment in environments: + if(len(sys.argv) > 1): + subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) # Iterate over the subfolders in the firmware folder for subfolder in os.listdir(firmware_folder): diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index a20b559..845de70 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -395,6 +395,11 @@ void ota_begin() otabuffer+=ota_part2_1+"IP Address"+ota_part2_2+IP.toString()+ota_part2_3; otabuffer+=ota_part2_1+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3; otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+ota_part2_3; + #ifdef FW_VERSION + otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+FW_VERSION+ota_part2_3; + #else + otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+"Out of Tree"+ota_part2_3; + #endif otabuffer+=ota_part2_1+"BMS Server"+ota_part2_2+MQTT_SERVER.toString()+ota_part2_3; otabuffer+=ota_part2_1+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3; otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2; From ed85d0714878fdea0c68d9e349e76e124b3440cd Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 14:59:39 +0700 Subject: [PATCH 04/12] Update gen_release.py --- gen_release.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gen_release.py b/gen_release.py index 34587da..5e91300 100644 --- a/gen_release.py +++ b/gen_release.py @@ -2,7 +2,6 @@ import os import shutil import subprocess import sys -import platform import subprocess import os import shutil From 8ca7c5407de63531b92ee08a4c7b05384143b31c Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:43:11 +0700 Subject: [PATCH 05/12] ci integration --- Jenkinsfile | 19 +++++++++++++++++++ gen_release.py | 16 ++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..971e5f9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,19 @@ +pipeline { + agent any + + stages { + stage('Build') { + steps { + sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' + sh 'python gen_release.py' + } + } + stage('Publish') { + steps { + sh 'mkdir -p artifacts' + sh 'cp -r release/ artifacts/' + archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true + } + } + } +} diff --git a/gen_release.py b/gen_release.py index 5e91300..0791e79 100644 --- a/gen_release.py +++ b/gen_release.py @@ -22,8 +22,16 @@ firmware_folder = os.path.join(current_dir, 'firmware') # Define the path to the release folder release_folder = os.path.join(current_dir, 'release') -# Add the path to the PlatformIO executable to the system PATH -platformio_path = os.path.expanduser('~/.platformio/penv/Scripts') +# Get the platformio path from environment variable +platformio_path = os.environ.get('PLATFORMIO_PATH') +# If the environment variable is not set, use the default path +if platformio_path is None: + if platform.system() == 'Darwin': + platformio_path = os.path.expanduser('~/.platformio/penv/bin/platformio') + elif platform.system() == 'Windows': + platformio_path = os.path.expanduser('~/.platformio/penv/Scripts/platformio.exe') + elif platform.system() == 'Linux': + platformio_path = os.path.expanduser('~/.platformio/penv/bin/platformio') if os.path.exists(release_folder): # If the release folder exists, delete it @@ -79,11 +87,11 @@ for environment in environments: # if argument is not supplied, build all environments listed in platformio.ini if len(sys.argv) == 1: - subprocess.run([f'{platformio_path}/platformio.exe', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) + subprocess.run([f'{platformio_path}', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) for environment in environments: if(len(sys.argv) > 1): - subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) + subprocess.run([f'{platformio_path}', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) # Iterate over the subfolders in the firmware folder for subfolder in os.listdir(firmware_folder): From 2b728b55c5023aaf4fcae0eb13a70e3e9eba4e79 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:45:02 +0700 Subject: [PATCH 06/12] Update Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 971e5f9..3c70497 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,11 @@ pipeline { agent any stages { + stage('Clone') { + steps { + git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' + } + } stage('Build') { steps { sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' From 816d31ad5f82307e99cc66e8407b1a0486b2c90b Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:46:36 +0700 Subject: [PATCH 07/12] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3c70497..54ce469 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Build') { steps { sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' - sh 'python gen_release.py' + sh 'python3 gen_release.py' } } stage('Publish') { From 5f5176969f64b457bb3b4f1913bc76300310e743 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:47:42 +0700 Subject: [PATCH 08/12] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54ce469..9ef0dd4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Build') { steps { sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' - sh 'python3 gen_release.py' + sh '/usr/bin/python3 gen_release.py' } } stage('Publish') { From 1988bc953e07c3df38a2e2494120640a27cb0b05 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:52:14 +0700 Subject: [PATCH 09/12] Update gen_release.py --- gen_release.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gen_release.py b/gen_release.py index 0791e79..24fa03b 100644 --- a/gen_release.py +++ b/gen_release.py @@ -19,6 +19,10 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) # Define the path to the firmware folder firmware_folder = os.path.join(current_dir, 'firmware') +# Create the firmware folder if it does not exist +if not os.path.exists(firmware_folder): + os.makedirs(firmware_folder) + # Define the path to the release folder release_folder = os.path.join(current_dir, 'release') From bc85bcf6015312b83a0272ab9e215c1cf1baf540 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 16:02:28 +0700 Subject: [PATCH 10/12] Update Jenkinsfile --- Jenkinsfile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9ef0dd4..dcf9353 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,22 +2,18 @@ pipeline { agent any stages { - stage('Clone') { - steps { - git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' - } - } stage('Build') { steps { + git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' sh '/usr/bin/python3 gen_release.py' + stash includes: 'release/**/*', name: 'release_binaries' } } stage('Publish') { steps { - sh 'mkdir -p artifacts' - sh 'cp -r release/ artifacts/' - archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true + unstash 'release_binaries' + archiveArtifacts artifacts: 'release/**/*', fingerprint: true } } } From 24871d2316e2dfa14874a12c00f9f16a6c675d7c Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 16:09:42 +0700 Subject: [PATCH 11/12] Update platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index b32f365..da29e98 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -build_dir = .\firmware +build_dir = firmware [env:full] platform = espressif32 From 59d0c470b11f9f81e3ebfe537862a0ee20f5a7e6 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 16:45:56 +0700 Subject: [PATCH 12/12] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dcf9353..1b77434 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stages { stage('Build') { steps { - git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' + git branch: 'modbus', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' sh '/usr/bin/python3 gen_release.py' stash includes: 'release/**/*', name: 'release_binaries'