【问题标题】:Jenkins - shell script - find parameter format not correctJenkins - shell 脚本 - 发现参数格式不正确
【发布时间】:2021-01-27 09:28:52
【问题描述】:

希望你们中的一个可以提供帮助-我正在jenkins管道中运行一个脚本,以便我可以将源地图上传到rollbar,所以我需要遍历缩小的js文件-我正在尝试使用FIND命令但是它一直给我一个错误:find parameter format not correct - 下面的脚本:

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

【问题讨论】:

  • 请发布错误信息。你也有一个shell脚本。不是蝙蝠脚本。请更改标题。
  • 在 bash 命令行中是否可以使用相同的命令?您可以检查 jenkins 是否使用不同的 find 命令 (which find)
  • 当我从 bash CLI 运行脚本时 - 我不断收到 curl 无法连接到 api.rollbar.com 端口 443 超时 我尝试使用:post_server_item 和 post_client_item 访问令牌脚本
  • 但是 find 命令在 bash CLI 中有效
  • 您是否确认distdist/renew 都是有效路径,并且它们存在于脚本运行的位置?

标签: jenkins jenkins-pipeline path-finding rollbar


【解决方案1】:

在@jeb 的帮助下,我设法通过在 shell 脚本中放置 (find) 的绝对路径来解决 jenkins 上的这个 FIND 问题 - 最初它使用的是 windows FIND cmd,所以我需要指向 cygwin find cmd

之前:对于 $(find dist/renew -name "*.js") 中的路径;做

及之后:对于 $(/usr/bin/find dist/renew -name "*.js") 中的路径;做

感谢所有评论

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2022-11-24
    • 2015-06-29
    • 2022-11-29
    • 1970-01-01
    • 2019-03-25
    相关资源
    最近更新 更多