GitLab Pipeline Sample Code
The sample code is as follows:
stages:
- code-inspector
code-inspector:
stage: code-inspector
tags:
- kunpeng_scanner # This is the tag used during gitlab-runner registration. Multiple tags may be selected.
rules:
- if: '$CI_PROJECT_ID == "11" && $CI_PIPELINE_SOURCE == "merge_request_event"' # Executes only merge requests of the current project.
script:
- echo '====== Specification check ======'
- set -- $(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA)
- export JAVA_HOME=/root/bisheng-jdk-11.0.10
- /home/Kunpeng_staff/code-inspector-1.0.0/bin/code-inspector $@ -o ./output.txt
artifacts:
when: always
paths:
- output.txt
name: src-code-check
- You are advised to perform code specification checks before the build process.
- /root/bisheng-jdk-11.0.10 specifies the JDK installation path. Replace it with the actual path.
- /home/Kunpeng_staff/code-inspector-1.0.0/bin/code-inspector specifies the full path to the Code Inspector. Replace it with the actual path.
- $@ is a variable set in set -- $(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA). It specifies a list of files for modification. The Code Inspector checks the code specification of these files.
Parent topic: Code Inspector