Search code examples
yamlcypresscicdbitbucket-pipelines

Bitbucket Pipelines - "The term 'chmod* is not recognized" error


I'm a beginner to pipelines in Bitbucket. I have a project with a .ymal file that I need to push to bitbucket, which would trigger a pipeline. However the triggered pipeline will not complete successfully and produces the following error message:

+ chmod - R +× $BITBUCKET_ CLONE DIR/*
Invoke-Expression: The term 'chmod* is not recognized as the name of a cmdlet, function, script file, or operal program. Check the spelling of the name, or if a path was included, verify that the path is correct and try aga.
At C: \…….. char: 40
"chmod -R +x $BITBUCKET_CLONE_DIR/** | Invoke-Expression
+
+ CategoryInfo
ObjectNotFound: (chmod:String) [Invoke-Expression], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException, Microsoft.PowerShell.Commands . InvokeExpressionCommand

Can someone please explain to me what is error is and how I can fix this?

Here is my .ymal file:

definitions:
    steps:
        step: &run_on_self_hosted_runner
            runs-on:
                - self.hosted
                - windows
                - savalktest

pipelines:
    default:
    - step:
        name: 'DA_cypress_Test Pipeline'
        image: cypress/base: 8
        <<: *run_on_self_hosted runner
        script:
                        - chmod -R + $BITBUCKET CLONE DIR/*
                        - $BITBUCKET_CLONE_DIR/DA/bitbucketscript/project-init.sh
                        #- cd background translations
                        #- npm install
                        #- npm run start &
                        #- px cypress run --browser chrome
                        #- sleep 600
        after-script:
                        echo "Exit status is :$BITBUCKET EXIT CODE"
                        - if [[$BITBUCKET_EXIT_CODE=-0]] ;then BUILD_ STATUS-"Pass"; exit 0;
        artifacts:
            - DA/reports/**
            - DA/cypress/videos/**
            - DA/cypress/screenshots/**

Any help with fixing this is much appreciated... :D


Solution

  • Looks like you're running on a Windows agent, chmod is the linux commandline tool to change the 'permissions' on files and folders, it's not used on windows.

    You can probably omit the chmod -R + $BITBUCKET CLONE DIR/* step completely.

    But it also looks like the step is being executed in PowerShell instead of bash, so after fixing this you'll encounter more error messages. I think, but I'm not 1005 sure, you'll have to port your scripts to PowerShell if you're running on windows