环境变量可在流水线中通过使用键值对以便重复手动更新相同的值。环境变量让开发人员节省查找和输入访问信息的时间,并消除在其脚本中提供敏感详细信息的风险。 ENV变量用于参数化构建脚本,在流水线中设置变量将致使相同的构建操作根据流水线以不同的方式工作。设置环境变量 添加新变量时,以下字段可用:权限范围定义变量的权限范围级别加密启用加密将隐藏日志中的变量值类型如果您设置为固定,变量的值将始终不变。切换选项至可设置将让您更改值并将其传递给下一个操作或执行。 环境变量分为4个级别:工作区适用于所有项目和流水线,在工作区选项中配置。项目可用于项目中的所有流水线,在项目选项中配置。流水线仅适用于所创建的流水线(例如,生产服务器信息),在流水线中配置。操作仅适用于定义变量的操作 危险 每个后续层都将覆盖更高层次的值。例如,如果您有两个相同的变量:一个在工作区级别定义,另一个在流水线级别定义,Buddy将使用该流水线中的流水线设置值以及帐户其余部分的工作区值。 信息 了解有关传递参数的更多信息使用示例 让我们配置一些变量来加密对FTP服务器的访问:转到您的部署流水线并点击变量选项卡添加具有相应值的变量,例如:Hostname:FTPHOST192。168。0。100Login:FTPLOGINadminPassword:FTPPASSbuddy1234 现在,您可以使用变量将访问凭据存储访问到部署服务器: 支持环境变量字段 整个服务都支持环境变量,但最常用于构建操作。您可以通过在支持字段的开头输入来预设变量: 以下是当前支持的字段列表: 操作名称 支持字段 AmazonS3 SourcePath,RemotePath,TagObjectsValue AWSCLI RunCommands AWSCLI2 RunCommands AWSECS SourcePath AWSLambdaDeploy SourcePath AWSLambdaTrigger Payload AzureAppService URL,Login,Password AzureCLI RunCommands AzureStorage SourcePath,RemotePath BuildAndroidApp RunCommands,MountFilesystemPath,MountContainerPath,Workingdir BuildAndroidReactNativeApplication RunCommands,MountFilesystemPath,MountContainerPath,Workingdir BuildDockerImage Name,Value BuildFlutterApp RunCommands,MountFilesystemPath,MountContainerPath,Workingdir BuildIonicapp MountFilesystemPath,MountContainerPath,Workingdir Bugsnag APIKey,Version,Revision,BuilderName,ReleaseStage CloudFront BaseURL,SourcePath Cloudflare BaseURL CodeDeploy SourcePath,BucketName,Description Compressimages SourcePath,DestinationPath Copyfiles SourcePath,RemotePath CustomBuild RunCommands,MountFilesystemPath,MountContainerPath,Workingdir Datadog EventTitle,Content,Host,Tags,AggregationKey DatadogServiceCheck Hostname,Check DigitalOceanDroplet SourcePath,Port,Login,Password,RemotePath,SSHKeyPassphrase DigitalOceanSpaces SourcePath,RemotePath DigitalOceanSpacesCDN BaseURL Discord Channel,Attachments,Message Dockerfile BuildArguments DockerfileLinter Dockerfile,YAMLfilewithignores ElasticBeanstalk Source,Version,Bucket1,Environment2 Email Subject,Attachments,Message ESLint MountFilesystemPath,MountContainerPath,Workingdir Findreplace SourcePath,Replacements Firebase MountFilesystemPath,MountContainerPath,Workingdir FTP SourcePath,Hostname,Port,Login,Password,RemotePath FTPDownload Hostname,Port,Login,Password,SourcePath,DestinationPath FTPS SourcePath,Hostname,Port,Login,Password,RemotePath FunctionDeploy GCE SourcePath,Hostname,Port,Login,Password,RemotePath GCloudCLI RunCommands GCS SourcePath,RemotePath GhostInspector Path GitPush URL,Login,Password Gitcryptlock Gitcryptunlock GoogleAppEngine SourcePath,Bucket,Version,ImageURL GoogleCDN BaseURL GoogleCloudCLI RunCommands GoogleCloudFunctions SourcePath GoogleCloudStorage SourcePath,RemotePath GoogleComputeEngine SourcePath,Hostname,Port,Login,Password,RemotePath GoogleFunctionTrigger Heroku HerokuCLI RunCommands Honeybadger Environment HTTP EndpointURL,Login,Password,Requestheaders Imagecompression Source,Destination KubernetesApply Server,Username,Password,SourcePath,PruneWhitelist,GracePeriod KubernetesCLI Server,Username,Password,RunCommands RunKubernetesJob Server,Username,Password,YAML RunKubernetesPod Server,Username,Password,YAML SetKubernetesImage Server,Username,Password,ImageName,ImageTag LambdaDeploy SourcePath LambdaTrigger Qualifier Linkvalidator URL Lighthouse URL LocalShell Loggly Tags Monitoring Environment3,Application4 MSTeams Channelemail,Title,Attachmentsfromfilesystem Netlify NewRelic Description,Changelog,Version Passarguments PHPCodeSniffer MountFilesystemPath,MountContainerPath,Workingdir Ping Host PublishAPKtoGooglePlay APK,Mainexpansionfile,Patchexpansionfile,ServiceKey,Packagename,Mappingfile Pushbullet Title,URL,Message PushDockerImage Login,Password,Repository,Tags Pushover Title,URL,URLTitle,Message Rackspace SourcePath,RemotePath Raygun AccessToken,APIKey,Version,User,Email,Comment Replace SourcePath,Replacements(name) Rollbar Environment,Comment,Username,RollbarUsername Rsync SourcePath,Hostname,Port,Login,Password,RemotePath RunDockerImage Login,Password,Image,Version,CMD,Entrypoint RunHelmCMDs RunCommands,Server,Username,Password Runnextpipeline Comment Sentry ReleaseVersion,DeployEnvironment,ReleaseURL,DeployURL,Repository SentryOnpremises ReleaseVersion,DeployEnvironment,ReleaseURL,DeployURL,Repository SignAPK SelecttheAPK,Location,KeystorePassword,KeyAlias,OutputDirectory,OutputAPKName SFTP SourcePath,Hostname,Port,Login,Password,RemotePath,PrivateSSHKey,SSHKeyPassphrase SFTPDownload Hostname,Port,Login,Password,SourcePath,DestinationPath,PrivateSSHKey,SSHKeyPassphrase Shopify SourcePath Slack Attachments,Message Sleep SMS Message S3Download SourcePath,Destination Splittests TestsPath SSH SourcePath,Hostname,Port,Login,Password,RemotePath SSLverify WebsiteURL TCP Host,Port,StringToSend,StringToExpect ThemeKitCLI RunCommands Telegram Attachments,Message UpCloud SourcePath,Port,Login,Password,RemotePath,SSHKeyPassphrase Visualtests Vultr SourcePath,Port,Login,Password,RemotePath Waitforapproval Question WEB URL,CheckForString,Login,Password,Requestheaders WebDAV SourcePath,Hostname,Login,Password ZIP SourcePath,TargetPath,FileName 14这些字段在前端不可用。但是,如果通过RESTAPI或YAML添加操作,则变量正常工作。 危险 有些字段是HTML文本区域,不支持推荐使用变量。例如,通知中的消息字段。但是它们确实完全支持ENVVAR。 提示 您还可以在列出的操作中使用多行环境变量 信息 如果您在此处未找到您的操作或必填字段不受支持,请联系客服:supportbuddy。red默认环境变量 Buddy在每次执行期间填充许多环境变量例如您部署的分支和执行的ID。以下是填充变量列表: 名称 值 BUDDY RepresentswhetherthecurrentenvironmentisaBuddyenvironment BUDDYWORKSPACEURL TheURLoftheworkspace BUDDYWORKSPACEID TheIDoftheworkspace BUDDYWORKSPACENAME TheIDoftheworkspace BUDDYWORKSPACEDOMAIN Theslugoftheworkspace BUDDYPROJECTURL TheURLoftheproject BUDDYPROJECTNAME Thenameoftheproject BUDDYPROJECTNAMEID TheIDoftheproject BUDDYREPOSLUG Theslugoftherepository BUDDYREPOSSHURL TheSSHURLoftherepository BUDDYSCMURL TheURLoftherepositorysynchronizedwiththeproject BUDDYSCMPROVIDER ThenameoftheGithostingprovidersynchronizedwiththeproject BUDDYPIPELINEURL TheURLoftheexecutedpipeline BUDDYPIPELINEID TheIDoftheexecutedpipeline BUDDYPIPELINENAME Thenameoftheexecutedpipeline BUDDYPIPELINEREFNAME Thebranchtagpullrequestorawildcardstringsetintheexecutedpipeline BUDDYPIPELINETRIGGERMODE Thetriggermodesetintheexecutedpipeline BUDDYPIPELINETARGETSITEURL ThetargetwebsiteURL BUDDYINVOKERURL TheURLtotheprofileoftheexecutioninvoker BUDDYINVOKERID TheIDoftheexecutioninvoker BUDDYINVOKERNAME Thenameoftheexecutioninvoker BUDDYINVOKEREMAIL Theemailaddressoftheexecutioninvoker BUDDYINVOKERAVATARURL TheURLoftheavataroftheexecutioninvoker BUDDYEXECUTIONURL TheURLofthecurrentexecution BUDDYEXECUTIONID TheIDofthecurrentexecution BUDDYEXECUTIONSTARTDATE Thedateofthecurrentexecution BUDDYEXECUTIONMODE Thetriggermodeusedtorunthecurrentexecution BUDDYEXECUTIONCLEARCACHE Representswhetherthecachewaspurgedbeforethecurrentexecution BUDDYEXECUTIONREFRESH Representswhetherthefileswereuploadedfromscratchbythedeploymentactionsinthecurrentexecution BUDDYEXECUTIONCOMMENT Thecommentattachedtothecurrentexecution BUDDYEXECUTIONBRANCH ThenameoftheGitbranchofthecurrentexecution BUDDYEXECUTIONTAG ThenameoftheGittagofthecurrentexecution(providedtheexecutionistagged) BUDDYEXECUTIONPULLREQUESTID TheIDofthecurrentlyexecutedpullrequest BUDDYEXECUTIONPULLREQUESTNO Thenumberofthecurrentlyexecutedpullrequest BUDDYEXECUTIONPULLREQUESTBASEBRANCH ThenameoftheGitBASEbranchofthecurrentlyexecutedPullRequest BUDDYEXECUTIONPULLREQUESTHEADBRANCH ThenameoftheGitHEADbranchofthecurrentlyexecutedPullRequest BUDDYEXECUTIONPREVIOUSREVISION TheSHA1hashofthecommitofthepreviousexecution BUDDYEXECUTIONPREVIOUSREVISIONMESSAGE Thecommitmessageofthepreviouslyexecutedrevision BUDDYEXECUTIONPREVIOUSREVISIONSUBJECT Thecommitsubjectofthepreviouslyexecutedrevision BUDDYEXECUTIONREVISION TheSHA1hashofthecommitofthecurrentexecution BUDDYEXECUTIONREVISIONURL TheURLofthecommitofthecurrentexecution BUDDYEXECUTIONREVISIONSHORT Theshorthashofthecommitofthecurrentexecution BUDDYEXECUTIONREVISIONMESSAGE Thecommitmessageofthecurrentlyexecutedrevision BUDDYEXECUTIONREVISIONSUBJECT Thecommitsubjectofthecurrentlyexecutedrevision BUDDYEXECUTIONREVISIONCOMMITTEREMAIL Theemailaddressofthecommiteremailofthecurrentlyexecutedrevision BUDDYEXECUTIONREVISIONCOMMITTERNAME Theemailaddressofthecommiterofthecurrentlyexecutedrevision BUDDYEXECUTIONCHANGELOG Thelistofcommitspushedsincethelastexecutedrevision(onecommitperline) BUDDYEXECUTIONCHANGELOGADDED Thelistoffilesaddedsincethelastexecutedrevision(commaseparated) BUDDYEXECUTIONCHANGELOGDELETED Thelistoffilesdeletedsincethelastexecutedrevision(commaseparated) BUDDYEXECUTIONCHANGELOGCHANGED Thelistoffileschangedsincethelastexecutedrevision(commaseparated) BUDDYEXECUTIONTIME Thetotaltimeofthecurrentexecutionuntiltheactionistriggered(inseconds) BUDDYFAILEDACTIONLOGS Thelogsfromtheactionthathasfailedinthecurrentexecution(oneentryperline) BUDDYFAILEDACTIONNAME Thenameoftheactionthathasfailedinthecurrentexecution BUDDYEXECUTIONWARNINGSCOUNT Thetotalnumberofwarningsthatappearedinthecurrentexecution CI RepresentswhetherthecurrentenvironmentisanotherCIenvironment 您可以在下面找到上述变量的示例值列表:BUDDYtrueBUDDYWORKSPACEURLhttps:app。buddy。worksmyworkspaceBUDDYWORKSPACEID1BUDDYWORKSPACENAMEMyWorkspaceBUDDYWORKSPACEDOMAINmyworkspaceBUDDYPROJECTURLhttps:app。buddy。worksmyworkspacemyprojectBUDDYPROJECTNAMEmyprojectBUDDYPROJECTNAMEIDmyprojectBUDDYREPOSLUGbuddyworksmyprojectBUDDYREPOSSHURLgitgithub。com:buddyworksmyprojectBUDDYSCMURLhttps:github。combuddyworksmyprojectBUDDYSCMPROVIDERGITHUBBUDDYPIPELINEURLhttps:app。buddy。worksmyworkspacemyprojectpipelinespipeline1BUDDYPIPELINEID1BUDDYPIPELINENAMEDeploytoProductionBUDDYPIPELINEREFNAMEmasterBUDDYPIPELINETRIGGERMODECLICKBUDDYPIPELINETARGETSITEURLhttps:buddy。worksBUDDYINVOKERURLhttps:app。buddy。worksmyworkspaceprofile1BUDDYINVOKERID1BUDDYINVOKERNAMEMikeBensonBUDDYINVOKEREMAILmikebensonbuddy。worksBUDDYINVOKERAVATARURLhttps:app。buddy。worksimageserveruser000000105d20f3d58ce09a3b4e9g3334a810603w3232AVATAR。pngBUDDYEXECUTIONURLhttps:app。buddy。worksmyworkspacemyprojectpipelinespipeline1execution5d9dc42c422f5a268b389d08BUDDYEXECUTIONID1BUDDYEXECUTIONSTARTDATE20190101T11:27:40。140ZBUDDYEXECUTIONMODECLICKBUDDYEXECUTIONCLEARCACHEfalseBUDDYEXECUTIONREFRESHfalseBUDDYEXECUTIONCOMMENTMyfirstexecutionBUDDYEXECUTIONBRANCHmasterBUDDYEXECUTIONTAGv1。0BUDDYEXECUTIONPULLREQUESTIDpull1BUDDYEXECUTIONPULLREQUESTNO1BUDDYEXECUTIONPULLREQUESTBASEBRANCHmasterBUDDYEXECUTIONPULLREQUESTHEADBRANCHmasterfeature1BUDDYEXECUTIONREVISIONe5e13f8b7f8d5c6096a0501dc09b48eef05fea96BUDDYEXECUTIONREVISIONURLhttps:app。buddy。worksmyworkspacemyprojectrepositorycommite5e13f8b7f8d5c6096a0501dc09b48eef05fea96BUDDYEXECUTIONREVISIONSHORTe5e13f8BUDDYEXECUTIONREVISIONMESSAGECreatebuddy。ymlBUDDYEXECUTIONREVISIONSUBJECTCreatebuddy。ymlBUDDYEXECUTIONREVISIONCOMMITTEREMAILmikebensonbuddy。worksBUDDYEXECUTIONREVISIONCOMMITTERNAMEMikeBensonBUDDYEXECUTIONCHANGELOG〔e5e13f8〕Createbuddy。ymlmikebenson20190101T07:14:58BUDDYFAILEDACTIONNAMEUploadfiles将变量组合成词组 变量可以与其他词组合以创建更长的短语,例如,自动命名您的基础设施、版本或沙盒。但是您需要遵守以下规则:变量之前:允许任何字符变量之后:不允许字母、数字和下杠() 正确用法:releaseBUDDYEXECUTIONIDstagingreleaseBUDDYEXECUTIONID:stagingreleaseBUDDYEXECUTIONID〔staging〕 错误用法:releaseBUDDYEXECUTIONIDstaging(下杠)releaseBUDDYEXECUTIONIDstaging(字母)releaseBUDDYEXECUTIONID1staging(数字)传递变量 在一个流水线中传递变量很有用。例如,当我们要将文件内容分配给变量并在通知中发送时: 信息第一个操作构建应用程序并将日志输出保存到logs。txt如果构建失败,LocalShell操作会用exportLOGS(catlog。txt)将logs。txt的内容分配给一个变量。然后将日志以LOGS作为消息内容发送到Slack频道。 危险 确保将变量设置为可设置,否则将无法更改其值。运行之间传递变量 您也可以在运行之间传递变量的值。这些值可以保存在一个运行中,然后在另一个运行中使用,例如,您可以使用版本类型设置变量并在每次执行时递增。 信息 您可以在我们的专用指南中阅读有关语义化版本控制的更多信息。流水线之间传递变量 您可以使用运行下一个流水线操作在流水线之间传递变量:进入操作信息中的变量选项卡定义变量的名称和要传递的值: 信息 您可以将目标流水线中的任何变量分配为值运行之间重置变量 要在流水线执行之间重置可设置的变量,您可以添加一个带有命令的操作,该命令将清除变量的值(最好在流水线的开头或结尾处):exportmySettableEnv 运行开始时传递变量 您可以使用传参操作参数化您的执行它会暂停流水线并等待您的输入继续: