rundeck / rundeck-cli

CLI tool for Rundeck
https://rundeck.github.io/rundeck-cli/
Apache License 2.0
132 stars 49 forks source link

Does $RD_OPTION_PROJECTS exist? #347

Closed duchenpaul closed 3 years ago

duchenpaul commented 3 years ago

I saw this issue https://github.com/rundeck/rundeck-cli/issues/122, look a person used $RD_OPTION_PROJECTS to get all projects, does this env var exist? I don't see it works on my instance

duchenpaul commented 3 years ago

Here is my job definition, I would like to sync all projects to SCM periodly

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 1e00be2f-32ed-4d13-96eb-21ff21242a58
  loglevel: INFO
  name: sync_rundeck_config
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - description: Sync up rundeck config
      script: "#!/bin/bash\n\nRD_OPTION_PROJECTS=uranus-ubuntu\n\necho $RD_OPTION_PROJECTS\n\
        \nenv | grep RD_ | sort\ndate\nsleep 5\n\nhostname\n\nfor PROJECT in $RD_OPTION_PROJECTS;\
        \ do\n    STATUS=`rd projects scm status --project $PROJECT --integration\
        \ export`\n\n    echo \"Current status for $PROJECT:\"\n    echo \"$STATUS\"\
        \n    echo \"\"\n\n    SYNCH_STATE=`echo \"$STATUS\" | grep synchState | sed\
        \ \"s/synchState: \\(.*\\)$/\\1/\"`\n    \n    if [ \"$SYNCH_STATE\" == \"\
        EXPORT_NEEDED\" ]; then\n        echo \"Because synchState is $SYNCH_STATE,\
        \ we must commit/push to the remote repo\"\n    \n        ACTION=`echo \"\
        $STATUS\" | grep -A 1 actions | tail -n 1 | awk '{$1=$1};1'`\n        JOB_IDS=`rd\
        \ jobs list --project $PROJECT --outformat \"%id\" | head -n -1 | xargs echo`\n\
        \    \n        echo \"Performing a '$ACTION'...\"\n        rd projects scm\
        \ perform --project $PROJECT \\\n            --integration export \\\n   \
        \         --action $ACTION \\\n            --job $JOB_IDS \\\n           \
        \ --field message=\"Daily sync\"\n    \n        echo \"Performing a 'project-push'...\"\
        \n        rd projects scm perform --project $PROJECT --integration export\
        \ --action project-push\n    else\n        echo \"What should we do? Nothing?\"\
        \n    fi\ndone"
    keepgoing: false
    strategy: node-first
  uuid: 1e00be2f-32ed-4d13-96eb-21ff21242a58
gschueler commented 3 years ago

RD_OPTION_PROJECTS variable would be set by a job option named "projects", that is not defined automatically. I'm not sure how the other poster was generating the values for that variable, you might ask them. Closing, this is not an issue for rundeck-cli project. If you have usage questions, check out the rundeck-discuss mailing list