location / { content_by_lua_block { local cjson = require "cjson" local http = require "resty.http" local httpc = http.new()
ngx.req.read_body() local data = ngx.req.get_body_data() local json = cjson.decode(data) local after = json["after"] if ( after == "0000000000000000000000000000000000000000" ) then ngx.status = 200 ngx.say("delete branch do not need build") return end
local projectName = json["project"]["name"] local userName = json["user_name"] local ref = json["ref"] local branchName = string.sub(ref, 12) if ( branchName == "master" ) then ngx.status = 200 ngx.say("master branch do not need build") return end
local uri = "http://172.16.72.200:8080/job/DataWarehouse/buildWithParameters?userName=" uri = uri..userName.."&branchName="..branchName.."&projectName="..projectName local res, err = httpc:request_uri(uri, { method = "POST" })