简体   繁体   English

Azure DevOps 在 bash 任务中生成密码

[英]Azure DevOps generate a password inside of the bash task

I would like to generate a password inside of the bash task.我想在 bash 任务中生成密码。 I came up with the following:我想出了以下内容:

- task: Bash@3
    displayName: 'Bash generate password'
    inputs:
      targetType: 'inline'
      script: |
        password=$(cat /dev/urandom | tr -dc 'A-Za-z0-9_!@#$%^&*()\-+=' | fold -w 32 | head -n 1)

        echo "##vso[task.setvariable variable=password]$password"

Unfortunately this seems to be not working, cause the task is running forever.不幸的是,这似乎不起作用,因为任务一直在运行。 The agent is Linux machine.代理为Linux机。

This worked:这有效:

password=$(cat /dev/urandom | tr -dc 'A-Za-z0-9_!@#$%^&*()\-+=' | head -c24)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 bash 如果 azure devops 任务中的语句未执行 - bash if statement inside the azure devops task is not executing 在Azure DevOps Bash任务中使用XMLStarlet - Use XMLStarlet in Azure DevOps Bash task Azure DevOps 检查以下 bash 脚本(yml 管道)内的 KeyVault 中是否存在密码 - Azure DevOps check if password exist in KeyVault inside of the following bash script (yml pipeline) Azure Devops内联bash脚本子shell输出作为任务组的变量 - Azure Devops inline bash script subshell output as variable to task group 如何使 Azure devops 管道任务失败,专门针对 bash 脚本中的失败 - How to fail Azure devops pipeline task specifically for failures in bash script 使用 bash 任务在 Azure DevOps 中设置 Docker 环境变量 - Setting Docker environment variables in Azure DevOps using bash task Azure DevOps 管道,无法在 bash 任务中创建变量 - Azure DevOps pipeline, cannot create a variable in bash task Azure devops Bash IF语句 - Azure devops Bash IF statement 使用代理 Ubuntu-16.04 在 azure-devops 管道 bash cake 任务中获取 ##[error] Bash 以代码“1”退出 - Getting ##[error] Bash exited with code '1' in an azure-devops pipeline bash cake task with agent Ubuntu-16.04 无法找到可执行文件:“bash”错误:使用 Bash@3 Azure DevOps 任务的内联脚本 - Unable to locate executable file: 'bash" error : Inline script using Bash@3 Azure DevOps task
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM