Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
561 views
in Technique[技术] by (71.8m points)

Jenkins - shell script - find parameter format not correct

enter image description here hope one of you can help - I'm running a script in jenkins pipeline, so that I can upload source maps to rollbar, so I need to loop through the minified js files - I'm trying to do this with the FIND command but it keeps giving me an error: find parameter format not correct - script below:

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....'

From Bash CLI enter image description here

question from:https://stackoverflow.com/questions/65916274/jenkins-shell-script-find-parameter-format-not-correct

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With the help of @jeb I managed to resolve this FIND issue on jenkins by placing the absolute path for (find) in the shell script - initially it was using the windows FIND cmd, so i needed to point to cygwin find cmd

before: for path in $(find dist/renew -name "*.js"); do

and after: for path in $(/usr/bin/find dist/renew -name "*.js"); do

Thaks to all that commented


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...