没有变量,服务器调用将起作用,并且gitlab正在启动管道。
但是,当我向该调用中添加变量时,它会出错:“变量必须是键值字符串的映射”。
这是我的代码:
axios
.post(`https://gitlab.myurl.com/api/v4/projects/${projectId}/trigger/pipeline`, {
ref: branch,
token: token,
variables: { STAGING_AREA: 'testing1', NOTIFY_STATUS: true, SLACK_USER_ID: 'xxxxx' }
})
.then(res => {
console.log('pipeline started:', res.data.web_url);
})
.catch(error => {
console.error('errorMessage', error);
});
传递变量的正确语法是什么?
我做错了一件事。
NOTIFY_STATUS: true
似乎true只能作为字符串传递:
NOTIFY_STATUS: 'true'
完成此编辑后,我的代码工作正常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句