Jenkins - shell 脚本 - 发现参数格式不正确
Jenkins - shell script - find parameter format not correct
希望你们中的一个可以提供帮助——我是 运行 jenkins 管道中的一个脚本,这样我就可以将源映射上传到 rollbar,所以我需要遍历缩小的 js 文件——我正在尝试使用FIND 命令,但它一直给我一个错误:查找参数格式不正确 - 下面的脚本:
stages {
stage('Set correct environment link') {
steps {
script {
buildTarget = params.targetEnv
if(params.targetEnv.equals("prj1")){
linkTarget = "http://xxx.xxx.xx/xxx/"
} else if(params.targetEnv.equals(.......)..etc.
stage('Uploading source maps to Rollbar') {
steps {
sh ''' #!/bin/bash
# Save a short git hash, must be run from a git
# repository (or a child directory)
version=$(git rev-parse --short HEAD)
# Use the post_server_time access token, you can
# find one in your project access token settings
post_server_item=e1d04646bf614e039d0af3dec3fa03a7
echo "Uploading source maps for version $version!"
# We upload a source map for each resulting JavaScript
# file; the path depends on your build config
for path in $(find dist/renew -name "*.js"); do
# URL of the JavaScript file on the web server
url=${linkTarget}/$path
# a path to a corresponding source map file
source_map="@$path.map"
echo "Uploading source map for $url"
curl --silent --show-error https://api.rollbar.com/api/1/sourcemap \
-F access_token=$post_server_item \
-F version=$version \
-F minified_url=$url \
-F source_map=$source_map \
> /dev/null
done
'''
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
来自 Bash CLI
在@jeb 的帮助下,我通过在 shell 脚本中放置 (find) 的绝对路径,设法解决了 jenkins 上的这个 FIND 问题——最初它使用的是 windows FIND cmd ,所以我需要指向 cygwin find cmd
before: for path in $(find dist/renew -name "*.js");做
和之后:对于 $(/usr/bin/find dist/renew -name "*.js") 中的路径;做
感谢所有评论
stages {
stage('Set correct environment link') {
steps {
script {
buildTarget = params.targetEnv
if(params.targetEnv.equals("prj1")){
linkTarget = "http://xxx.xxx.xx/xxx/"
} else if(params.targetEnv.equals(.......)..etc.
stage('Uploading source maps to Rollbar') {
steps {
sh ''' #!/bin/bash
# Save a short git hash, must be run from a git
# repository (or a child directory)
version=$(git rev-parse --short HEAD)
# Use the post_server_time access token, you can
# find one in your project access token settings
post_server_item=e1d04646bf614e039d0af3dec3fa03a7
echo "Uploading source maps for version $version!"
# We upload a source map for each resulting JavaScript
# file; the path depends on your build config
for path in $(find dist/renew -name "*.js"); do
# URL of the JavaScript file on the web server
url=${linkTarget}/$path
# a path to a corresponding source map file
source_map="@$path.map"
echo "Uploading source map for $url"
curl --silent --show-error https://api.rollbar.com/api/1/sourcemap \
-F access_token=$post_server_item \
-F version=$version \
-F minified_url=$url \
-F source_map=$source_map \
> /dev/null
done
'''
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
来自 Bash CLI
在@jeb 的帮助下,我通过在 shell 脚本中放置 (find) 的绝对路径,设法解决了 jenkins 上的这个 FIND 问题——最初它使用的是 windows FIND cmd ,所以我需要指向 cygwin find cmd
before: for path in $(find dist/renew -name "*.js");做
和之后:对于 $(/usr/bin/find dist/renew -name "*.js") 中的路径;做
感谢所有评论