MSIPO技术圈 首页 IT技术 查看内容

Jenkins pipeline中读写文件

2024-03-28

下面是一个读写文件的示例,并且保证了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}"
                }
            }
        }
	}

}

相关阅读

热门文章

    手机版|MSIPO技术圈 皖ICP备19022944号-2

    Copyright © 2024, msipo.com

    返回顶部