This article is primarily used to assist in the writing of the build process and explain the parameter details of each step.
Prerequisites
Before configuring the CODING-CI build environment, you must activate the CODING DevOps service for your Tencent Cloud account. For details, please refer to Activate Services.
Open Project
1. log in to CODING console, click Team Domain to enter the CODING page.
2. After entering the target project, click on the left side Continuous Integration, click Build Plan > Text Editor and arrange within it.
Code Repository
Git
Used to check out the Git repository source code of the current project. This command is a simplified version of the checkout command.
Parameter List:
Parameter | Type |
Git Address url | string |
Branch branch | string |
Change Log changelog | string |
Identity Authentication ID credentialsId | string |
Poll poll | boolean |
Check out from Version Control
General checkout SCM (Git, SVN) code.
This step returns content in Map Format. For example, if you use Git, you can do this:
def scmVars = checkout scmdef commitHash = scmVars.GIT_COMMIT// ordef commitHash = checkout(scm).GIT_COMMIT
The parameter
scmis a configurable SCM type object. The currently supported ones are as follows:GitSCM Example Usage:
checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],userRemoteConfigs: [[url: env.GIT_REPO_URL]]])
userRemoteConfigs Parameter List:
Parameter | Type |
locations | Object array. |
remote | string. |
credentialsId | string. |
local | string, specify a local directory (relative to workspace) as the location for checking out code. |
depthOption | string, corresponds to the content of --depth. The default value is infinity. For details, refer to Subversion. |
ignoreExternalsOption | boolean. |
SubversionSCM checks out code from the SVN server. Example syntax:
checkout([$class: 'SubversionSCM', remote: 'http://sv-server/repository/trunk'])
Parameter List:
Parameter | Type |
locations | Object array. |
remote | string. |
credentialsId | string. |
local | string, specify a local directory (relative to workspace) as the location for checking out code. |
depthOption | string, corresponds to the content of --depth. The default value is infinity. For details, refer to Subversion. |
ignoreExternalsOption | boolean. |
Build Process
Subnode
Parameter List:
label: type string Environment Tag name, for example, java-8.Collect Build Artifacts
Collect build results (e.g., jar, war, apk, etc.). Note that the collected build artifacts will be saved and deleted along with this build history. This is only a temporary storage space. It is recommended to use "Build Management" for versioning build results.
Parameter List:
Parameter | Type |
artifacts | string, wildcards * can be used to specify the path pattern of files to be collected, conforming to the Apache Ant path rule. Only files within the workspace can be specified. |
allowEmptyArchive | boolean, optional; under normal circumstances, this directive will cause the build to fail if no files matching the collection pattern are found. If this option is set to true, the build process will issue a warning instead of failing when no build artifacts are found. |
caseSensitive | boolean, optional; by default, the matching of file path rules is case sensitive. If set to false, case sensitivity will be ignored. |
defaultExcludes | boolean, Optional. |
excludes | boolean, Optional; You can exclude some files within the specified path mode, also supports Apache Ant path rules |
fingerprint | boolean, Optional; Calculate the file's hash information at the time of collection. |
onlyIfSuccessful | boolean, Optional; Collect only if the build is successful. |
Execute Shell Script
Execute a Shell script, example:
pipeline {agent anystages {stage('Example') {steps {echo 'Hello World'sh 'ls -al'}}}}
Collect JUnit Test Report
Collect JUnit and TestNG test reports (XML Format). You can specify which XML files to collect, for example
**/build/test-reports/*.xml. Note that XML files that are not report files should not be included. You can use commas to separate multiple rules.Parameter List:
Parameter | Type |
testResults | string. |
allowEmptyResults | boolean, Optional, allows the test report file to be missing or empty. |
keepLongStdio | boolean, Optional, all test logs will be retained, even those of passed test cases. |
Other
Change Directory Sub-steps
Change directory sub-steps. You can fill in several sub-steps within the DIR block, and these sub-steps will be executed within the specified path directory.
Parameter List:
path: type string.Sleep
Pause for a period of time until the specified deadline. Similar to Unix's
sleep xxx.Parameter List:
time: Type: int.unit: Can only select one from NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS.Error
Send an error signal, often used when it is necessary to terminate part of the execution process based on conditions. You can also use throw new Exception(), but using the error step can avoid printing an excessively long exception stack.
Parameter List:
message: Type: string.Current Directory
Return the current directory path as a string.
Parameter List:
tmp: Type: boolean, optional. If selected, it returns a temporary directory associated with the workspace. Typically used when you want to store some temporary files without contaminating the workspace directory.Write File
Write the specified content to a file. Parameter List:
file: Type: string.text: Type: string.encoding: Type: string. Specifies the file encoding. If left blank, the default encoding of the current runtime platform will be used. For binary files, it will automatically be returned as a Base64-encoded result.Read File
Read a file from a relative path and return its content as a string. Parameter List:
file: Type: string. Relative path address (relative to the workspace directory).encoding: Type: string. Specifies the file encoding. If left blank, the default encoding of the current runtime platform will be used. For binary files, it will automatically be returned as a Base64-encoded result.Retry substeps
Retry a specified block until the maximum retry limit is reached. If it ends normally during execution, it will not retry. If an abnormal termination occurs, it will keep retrying until it reaches the maximum retry limit. If the last attempt fails, the build process will be terminated.
Parameter List:
count: Type: int.Time limit substeps
Execute the process within the block with a time limit. If time runs out, an
org.jenkinsci.plugins.workflow.steps.FlowInterruptedException will be thrown. The unit parameter is optional and defaults to minutes. Parameter List:time: Type: int.activity: Type: boolean. Time is measured based on the absence of new log content instead of absolute execution time.unit: Can only select one from NANOSECONDS,MICROSECONDS,MILLISECONDS,SECONDS,MINUTES,HOURS,DAYS.Catch error substeps
Errors in the specified substeps will be caught.
Timer substeps
Execution time of the specified substeps will be recorded as Unix timestamps.
Loop substeps
The specified substeps will be executed repeatedly for a defined number of times.
Conditional loop substeps
The specified substeps will be executed repeatedly until the result of the substeps returns
true.Print message
Print a message in the log.
Parameter List:
message: Type: stringExecute arbitrary Pipeline script
Adding this step allows you to execute any Pipeline script.
Execute Groovy source file
The build process will execute the Groovy source file at this location.
Example:
pipeline {agent anystages {stage('Example') {steps {echo 'Hello World'load 'test.groovy'}}}}
Execute Yarn Audit
This step performs yarn audit in the specified directory, and the vulnerabilities of yarn dependencies can be seen on the Continuous Integration results page.
Parameter List:
directory: Type: string, optional. Fill in the directory where yarn.lock is located. By default, it executes at the project root directory.collectResult: Type: boolean, optional. Collect the Yarn Audit report.Execute Npm Audit
This step performs npm audit in the specified directory, and the vulnerabilities of npm dependencies can be seen on the Continuous Integration results page.
Parameter List:
directory: Type: string, optional. Fill in the directory where package.json is located. By default, it executes at the project root directory.collectResult: Type: boolean, optional. Collect the Npm Audit report.Merge Merge Request
Merge Code. You can merge a specified merge request in this step.
Parameter List:
token: Type: string. Project token.depot: Type: string. Repository name.mrResourceId: Type: string. Specify Resource ID.commitMessage: Type: string. Merge commit message template.deleteSourceBranch: Type: boolean, optional. Delete source branch.fastForward: Type: boolean, optional. Attempt fast-forward merge.Review Merge Request
Review Merge Request. You can comment on a specified merge request in this step.
Parameter List:
token: Type: string. Project token.depot: Type: string. Repository name.mrResourceId: Type: string. Specify Resource ID.commentContent: Type: string. Comment content template.