From 85f0718bbbec8e02b5c94c37be742e3eeb741765 Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Mon, 17 Jun 2024 19:09:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9script=20generator?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=8E=BB=E6=8E=89=20kunpeng=5Fexecu?= =?UTF-8?q?tor=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/handler/generate_pipeline_script.py | 13 +++++++++---- .../pipeline_script_generator/gitlab_generator.py | 2 +- .../pipeline_script_generator/jenkins_generator.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/download_and_deploy/src/handler/generate_pipeline_script.py b/tools/download_and_deploy/src/handler/generate_pipeline_script.py index 335920b..cf7f46d 100644 --- a/tools/download_and_deploy/src/handler/generate_pipeline_script.py +++ b/tools/download_and_deploy/src/handler/generate_pipeline_script.py @@ -6,8 +6,13 @@ generator_class = (JenkinsScript, GitlabScript) class GeneratePipelineScript(Handler): def handle(self, data) -> bool: - for klass in generator_class: - o = klass(data) - with open("./script." + o.name, "w+", encoding="utf8") as f: - f.write(o.generate()) + try: + for klass in generator_class: + o = klass(data) + with open("./script." + o.name, "w+", encoding="utf8") as f: + f.write(o.generate()) + except Exception as e: + print("[ERROR] Generate pipeline script failed.") + return False + print("-- Generate pipeline script success. --") return True diff --git a/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py index 34e4c4f..a473fa4 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py @@ -224,7 +224,7 @@ java-performance-analysis: compatibility_test: # This job runs in the build stage, which runs first. stage: test tags: - - kunpeng_executor # 对应gitlab-runner注册时的标签,可选择多个 + - compatibility_test # 对应gitlab-runner注册时的标签,可选择多个 script: - CURDIR=$(pwd) - echo $CURDIR diff --git a/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py index 0c8213e..074d599 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py @@ -536,7 +536,7 @@ pipeline { // 鲲鹏兼容测试 stage('compatibility_test') { agent { - label 'kunpeng_executor' + label 'compatibility_test' } steps { script{ -- Gitee From d74f28bc24e997e371885d5038bcea287472ed3a Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Mon, 17 Jun 2024 19:56:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9JDK=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E9=87=8D=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/BiShengJDK17/install.sh | 3 ++- component/BiShengJDK8/install.sh | 3 ++- .../pipeline_script_generator/script_generator_command_line.py | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/component/BiShengJDK17/install.sh b/component/BiShengJDK17/install.sh index 97905e0..3aa3ad7 100644 --- a/component/BiShengJDK17/install.sh +++ b/component/BiShengJDK17/install.sh @@ -12,12 +12,13 @@ fi java_path=$(which java) if [[ ${java_path} != ${HOME}/.local/bisheng-jdk-17.0.10/bin/java ]]; then - sed -i '/bisheng-jdk-17.0.10/d' ${HOME}/.bashrc + sed -i '/bisheng-jdk-17.0.10/,+1d' ${HOME}/.bashrc echo "change ${HOME}/.bashrc" cat >> ${HOME}/.bashrc <<'EOF' export JAVA_HOME=${HOME}/.local/bisheng-jdk-17.0.10 export PATH=${JAVA_HOME}/bin:${PATH} + EOF echo "source ${HOME}/.bashrc" diff --git a/component/BiShengJDK8/install.sh b/component/BiShengJDK8/install.sh index 46062f3..f4bf6e9 100644 --- a/component/BiShengJDK8/install.sh +++ b/component/BiShengJDK8/install.sh @@ -12,7 +12,7 @@ fi java_path=$(which java) if [[ ${java_path} != ${HOME}/.local/bisheng-jdk1.8.0_402/bin/java ]]; then - sed -i '/bisheng-jdk1.8.0_402/d' ${HOME}/.bashrc + sed -i '/bisheng-jdk1.8.0_402/,+3d' ${HOME}/.bashrc echo "change ${HOME}/.bashrc" cat >> ${HOME}/.bashrc <<'EOF' @@ -20,6 +20,7 @@ export JAVA_HOME=${HOME}/.local/bisheng-jdk1.8.0_402 export PATH=${JAVA_HOME}/bin:${PATH} export CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar export JRE_HOME=${JAVA_HOME}/jre + EOF echo "source ${HOME}/.bashrc" diff --git a/tools/download_and_deploy/src/pipeline_script_generator/script_generator_command_line.py b/tools/download_and_deploy/src/pipeline_script_generator/script_generator_command_line.py index 5297307..dc411f1 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/script_generator_command_line.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/script_generator_command_line.py @@ -11,8 +11,6 @@ class CommandLine: def add_options(cls, parser): parser.add_argument("-f", "--config", action="store", dest="yaml_path", default=DEFAULT_YAML_PATH, help="Assign yaml config file path. Default path is 'machine.yaml' in current directory.") - parser.add_argument("--debug", action="store_true", dest="debug", default=True, - help="Open debug log. Default is True.") parser.add_argument("--silent", action="store_true", dest="silent", default=False, help="Close debug log.") @classmethod -- Gitee From ae2df235da933694de18a118cdc86f96a285d93f Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Tue, 18 Jun 2024 10:13:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E4=BF=AE=E6=94=B9jenkins?= =?UTF-8?q?/gitlab=20=E7=94=9F=E6=88=90=E8=84=9A=E6=9C=AC=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pipeline_script_generator/gitlab_generator.py | 8 +++++++- .../src/pipeline_script_generator/jenkins_generator.py | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py index a473fa4..5b09cc1 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py @@ -59,6 +59,9 @@ variables: # Devkit工具部署的环境IP DEVKIT_WEB_IP: "" + # 待病毒扫描的路径 + CLAMAV_PATH: "" + ##STAGES## """ source_migration_template = """ @@ -70,6 +73,9 @@ source-code-migration: script: - echo '====== 源码迁移 ======' - devkit porting src-mig -i ./ -c $SOURCE_CODE_COMMAND -r html || [ $? -eq 1 ] && echo 'Warning:扫描报告包含建议项' + # - devkit porting src-mig -i ./ -s interpreted -r html || [ $? -eq 1 ] && echo 'Warning:扫描报告包含建议项' + # - devkit porting src-mig -i ./ -c "${SOURCE_CODE_COMMAND}" -s asm -r html || [ $? -eq 1 ] && echo 'Warning:扫描报告包含建议项' + # - devkit porting src-mig -i ./ -s 'go' -b go -c 'go build' -r html || [ $? -eq 1 ] && echo 'Warning:扫描报告包含建议项' - mv ./src-mig*.html ./SourceCodeScanningReport.html artifacts: paths: @@ -246,7 +252,7 @@ clamscan: - kunpeng_clamav # 对应gitlab-runner注册时的标签,可选择多个 script: - freshclam - - clamscan -i -r ./ -l ./clamscan.log + - clamscan -i -r ${CLAMAV_PATH} -l ./clamscan.log artifacts: paths: - clamscan.log diff --git a/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py index 074d599..fed3314 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py @@ -75,10 +75,10 @@ pipeline { BUILD_COMMAND = ''' ''' - //A-FOT配置文件存放的路径 + // A-FOT配置文件存放的路径 A_FOT_CONF_PATH = "" - //病毒扫描路径 + // 待病毒扫描的路径 CLAMAV_PATH = "" } @@ -103,7 +103,7 @@ pipeline { devkit porting src-mig -i "./${GIT_TARGET_DIR_NAME}" -c "${SOURCE_CODE_COMMAND}" -r html -o ./report_dir # devkit porting src-mig -i "./${GIT_TARGET_DIR_NAME}" -s interpreted -r html -o ./report_dir # devkit porting src-mig -i "./${GIT_TARGET_DIR_NAME}" -c "${SOURCE_CODE_COMMAND}" -s asm -r html -o ./report_dir - # devkit porting src-mig -i "./${GIT_TARGET_DIR_NAME}" -s go -r html -o ./report_dir + # devkit porting src-mig -i "./${GIT_TARGET_DIR_NAME}" -s 'go' -b go -c 'go build' -r html -o ./report_dir ''') switch(STATUS_CODE) { case 0: -- Gitee