---
title: Jenkins流水线示例代码
description: "示例代码如下："
url: https://www.hikunpeng.com/document/detail/zh/nativedevp/userguide/pipeline/NativeDevelopment_0116.html
sourcePath: /source/zh/nativedevp/userguide/pipeline/NativeDevelopment_0116.html
indexId: e07b901a28b7057f7dd7556db2b8f4652591435389b4236ebe23f7c5bcc6b88b68
---
# Jenkins流水线示例代码

#### 不使用A-FOT

示例代码如下：

```
pipeline {
agent any    options {
timeout(time: 1, unit: 'HOURS')
}
stages{
stage('build') {
agent {
label 'kunpeng_c_builder_gcc'
}
steps{
# 安装完成后已有GCC for openEuler的环境，编译命令与其他平台保持一致。
cd
/home/test
# 执行原有的构建脚本
sh build.sh
}
}
}
}
```


“/home/test”指项目文件路径，请根据实际情况进行替换。


#### 使用A-FOT（配置文件参数优化）

示例代码如下：

```
pipeline {
agent any    options {
timeout(time: 1, unit: 'HOURS')
}
stages{
stage('A-FOT') {
agent {
label 'kunpeng_c_builder_gcc'
}
steps{
# 安装完成后已有GCC for openEuler的环境，编译命令与其他平台保持一致。
#################################
# 此处替换为用户实际场景的编译命令 #
#################################
sh 'a-fot --config_file a-fot.ini'
}
}
}
}
```


#### 使用A-FOT（命令行参数优化）

示例代码如下：

```
pipeline {
agent any    options {
timeout(time: 1, unit: 'HOURS')
}
stages{
stage('A-FOT') {
agent {
label 'kunpeng_c_builder_gcc'
}
steps{
sh 'a-fot --opt_mode AutoFDO --gcc_path
/usr
--run_script
/root/run.sh
--build_script
/root/build.sh
--build_mode Wrapper --work_path
./
--bin_file
/tmp/test
'
}
}
}
}
```

优化模式为AutoFDO，GCC路径为/usr，应用运行脚本路径为/root/run.sh，应用构建脚本路径为/root/build.sh，构建模式为Wrapper，脚本工作目录为当前目录，可执行二进制文件路径为/tmp/test，请根据实际情况进行替换。
