【发布时间】:2021-12-08 03:50:47
【问题描述】:
Gitlab-ci
st1:
stage: build
before_script:
- |+
function curling()
{
echo "ip are $1"
}
script:
- foo=$(curl +x socks5 ifconfig.co) # like get proxy ext ip
- boo=$(curl ifconfig.co) # like get my ext ip
- |+
if [ $foo -eq $foo ]
then
curling equal
else
curling not_equal
fi
when: manual
only:
- master
tags:
- tag
我想将作业数量增加到 3 个并在其中使用相同的功能。我可以定义一个函数并在不同的工作中使用它吗?
喜欢
stages:
-st1
-st2
-st3
st1:
stage: st1
script:
- |+
function curling()
{
echo "ip are $1"
}
st2:
stage: st2
script:
- foo=$(curl +x socks4 ifconfig.co) # like get first proxy ext ip
- boo=$(curl ifconfig.co) # like get my ext ip
- |+
if [ $foo -eq $foo ]
then
curling equal
else
curling not_equal
fi
when: manual
only:
- master
tags:
- tag
st3:
stage: st3
script:
- foo=$(curl +x socks5 ifconfig.co) # like get second proxy ext ip
- boo=$(curl ifconfig.co) # like get my ext ip
- |+
if [ $foo -eq $foo ]
then
curling equal
else
curling not_equal
fi
when: manual
only:
- master
tags:
- tag
这样做的目的是使用许多操作并通过具有相同模板的 echo/curl/webhook 消息报告它们的结果,其中几个单词不同,而不是多次重复相同的模板
【问题讨论】:
标签: bash function curl gitlab-ci