Jenkins pipeline中读写文件

下面是一个读写文件的示例,并且保证了nginx.conf中的$uri不被识别为变量

pipeline {
    agent any
	stages {
		stage('Write and Read File') {
			steps {
                script {
                    echo "Build Stage"
                    def content = """
server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    #gzip
    #开启gzip功能
    gzip on; 
    #开启gzip静态压缩功能
    gzip_static on; 
    #gzip缓存大小
    gzip_buffers 4 16k;
    #gzip http版本
    gzip_http_version 1.1;
    #gzip 压缩级别 1-10 
    gzip_comp_level 5;
    #gzip 压缩类型
    gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; 
    gzip_vary on; 
    location / {
        alias   /usr/share/nginx/html/;
        index  index.html index.htm;
        try_files \$uri \$uri/ /index.html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
                    """
                    writeFile(
                        file: 'default.conf',
                        text: content
                    )
                    def fileContent = readFile(file: 'default.conf')
                    echo "${fileContent}"
                }
            }
        }
	}

}

相关推荐

  1. Jenkins pipeline文件

    2024-03-27 14:50:01       43 阅读
  2. nodejsfs删除文件

    2024-03-27 14:50:01       31 阅读
  3. python文件

    2024-03-27 14:50:01       42 阅读
  4. 文件

    2024-03-27 14:50:01       34 阅读
  5. Python:文件

    2024-03-27 14:50:01       35 阅读
  6. pytorch文件

    2024-03-27 14:50:01       34 阅读
  7. Python 文件

    2024-03-27 14:50:01       24 阅读
  8. Python--文件

    2024-03-27 14:50:01       27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-27 14:50:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-27 14:50:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-27 14:50:01       82 阅读
  4. Python语言-面向对象

    2024-03-27 14:50:01       91 阅读

热门阅读

  1. Day24枚举

    2024-03-27 14:50:01       34 阅读
  2. 9个实用python实例

    2024-03-27 14:50:01       39 阅读
  3. 面试算法-120-全 O(1) 的数据结构

    2024-03-27 14:50:01       36 阅读
  4. DHCP snooping、DHCP安全及威胁防范

    2024-03-27 14:50:01       36 阅读
  5. 利用Emby搭建自己的家庭影院

    2024-03-27 14:50:01       42 阅读
  6. [C++提高编程](三):STL初识

    2024-03-27 14:50:01       40 阅读
  7. css中让div上下位置居中

    2024-03-27 14:50:01       39 阅读
  8. Git相关命令(二)

    2024-03-27 14:50:01       37 阅读
  9. spring spi

    2024-03-27 14:50:01       38 阅读
  10. 使用Spring Boot Admin监控和管理Spring Boot应用程序

    2024-03-27 14:50:01       38 阅读