我正在使用GitLab企业版11.1.4-ee,并且我有一个项目想要通过触发器启动其管道。
在此仓库中,我有2个以上分支,当然还有master。没有分支受到保护。
我已经根据documentation创建了一个管道触发器,并且我试图通过使用NodeJS发出POST请求来触发管道。这是代码。
const gitlab_url = 'my-gitlab-url.com';
const project_name = 'the-project-name'
const branch_name = 'master'
const id = 50;
const token = 'some-peculiar-token';
const trigger_path = '/api/v4/projects/'+id+'/ref/'+branch_name+'/trigger/pipeline?token='+token;
// code that makes the POST request to Gitlab
var http = require("http");
var options = {
hostname: gitlab_url,
port: 80,
path: trigger_path,
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
};
var req = http.request(options, function(res) {
console.log('Status: \n' + res.statusCode);
console.log('Headers: \n' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (body) {
console.log('Body: ' + body);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write('{"string": "Hello, World"}');
req.end();
我可以成功触发除master以外的任何其他分支。
当我触发devops
分支时,得到以下响应。
Status: 201
Headers: {"server":"nginx","date":"Fri, 05 Oct 2018 07:20:46 GMT","content-type":"application/json","content-length":"604","connection":"close","cache-control":"max-age=0, private, must-revalidate","etag":"W/\"40c1533ca55d0150e3f84c4a1e8b92\"","vary":"Origin","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-request-id":"57e9b458-92-4621-bf7a-ebafaa7697","x-runtime":"2.437610","strict-transport-security":"max-age=31536000"}
Body: {"id":3799,"sha":"fabc4d9c07e3d3b1645fd6445091fe3304b74a","ref":"devops","status":"pending","before_sha":"0000000000000000000000000000000000000000","tag":false,"yaml_errors":null,"user":{"id":1,"name":"Administrator","username":"something","state":"active","avatar_url":"http://my-gitlab-url.com/uploads/-/system/user/avatar/1/avatar.png","web_url":"http://gimy-gitlab-url.com/something"},"created_at":"2018-10-05T07:20:44.340Z","updated_at":"2018-10-05T07:20:46.039Z","started_at":null,"finished_at":null,"committed_at":null,"duration":null,"coverage":null}
但是,当我尝试触发master分支时,我得到了。
Status:
400
Headers:
{"server":"nginx","date":"Fri, 05 Oct 2018 07:42:31 GMT","content-type":"application/json","content-length":"60","connection":"close","cache-control":"no-cache","vary":"Origin","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-request-id":"20f46c-5a5-444a-ae2f-829545a49022","x-runtime":"0.161319"}
Body: {"message":{"base":["No stages / jobs for this pipeline."]}}
400
response status用于Malformed request
,但是,我认为它与POST请求无关,而与特定分支的Gitlab配置有关。这只是一个猜测,因为对其他分支的请求运行良好。
任何见识都会有所帮助。
答案 0 :(得分:1)
我不好!
我试图触发@override
Widget build(BuildContext context) {
return new StreamBuilder(
stream: globalWsStream,
builder: (context, snapshot) {
// from snapshot we can get new data
// add to globalData and start animation
if (snapshot.hasData) {
print('---why this called many times when state changed.');
_solveReceivedMessage(snapshot.data);
} else {
print('Chat 被锁住了不会进行任何操作');
}
return new CupertinoPageScaffold(
key: _scaffoldKey,
navigationBar: CupertinoNavigationBar(
previousPageTitle: '聊天',
// padding: new EdgeInsetsDirectional.only(top:8.0, bottom: 9.0),
// leading: new Text('聊天'),
actionsForegroundColor: GlobalConfig.cupertinoMainColor,
middle: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Text('${widget.sess.targetName}', style: new TextStyle(fontWeight: FontWeight.bold),),
new Text('对话中', style: new TextStyle(fontSize: 12.0, fontWeight: FontWeight.w200),)
]
),
trailing: CupertinoButton(
padding: new EdgeInsets.all(5.0),
child: Icon(
CupertinoIcons.ellipsis,
color: GlobalConfig.cupertinoMainColor,
// size: 10.0,
semanticLabel: 'Add',
),
onPressed: () {
Navigator.of(context).push(new CupertinoPageRoute(builder: (c) {
return new UserChatSettings();
}));
},
),
),
child: new GestureDetector(
onTap: () {
print("点击了");
_hideKeyboard('');
},
child: new Stack(
children: <Widget>[
new Container(
padding: new EdgeInsets.all(0.0),
child: globalAppSettings.isBlurBk
? new BackdropFilter(
filter:
new ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
child: new Container(
decoration: new BoxDecoration(
color: Colors.white.withOpacity(0.0)),
),
)
: null,
decoration: new BoxDecoration(
image: new DecorationImage(
// image: _getBkImage(),
image: !_hasCustomBk
// ? new AssetImage("assets/images/chat_bk_5.jpg")
? new AssetImage('assets/images/chat_bk_6.jpg')
: new FileImage(_chatBkFile),
fit: BoxFit.cover)),
),
new Container(
padding: new EdgeInsets.all(0.0),
child: new Container(child: _buildMsgList()),
),
new Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Container(
// color: Colors.white,
padding: new EdgeInsets.only(
top: 15.0, bottom: 15.0, left: 5.0, right: 5.0),
child: _buildComposer2())
],
),
],
)),
);
},
);
}
分支,但是我的master
文件中没有它。
gitlab-ci.yml