{"id":22061513,"url":"https://github.com/raojinlin/env-from-mr","last_synced_at":"2026-05-08T13:46:56.820Z","repository":{"id":203680706,"uuid":"710169711","full_name":"raojinlin/env-from-mr","owner":"raojinlin","description":"🐧 从GitLab Merge Request描述中提取环境变量","archived":false,"fork":false,"pushed_at":"2023-10-26T13:22:58.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T23:26:52.595Z","etag":null,"topics":["gitlab","gitlab-auto-devops","gitlab-ci","gitlab-ci-cd","gitlab-ci-pipeline","go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raojinlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-26T06:52:24.000Z","updated_at":"2023-10-26T13:12:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"daef5a14-5ccb-46db-b91f-a3cba8001f3a","html_url":"https://github.com/raojinlin/env-from-mr","commit_stats":null,"previous_names":["raojinlin/env-from-mr"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raojinlin%2Fenv-from-mr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raojinlin%2Fenv-from-mr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raojinlin%2Fenv-from-mr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raojinlin%2Fenv-from-mr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raojinlin","download_url":"https://codeload.github.com/raojinlin/env-from-mr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245139005,"owners_count":20567081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gitlab","gitlab-auto-devops","gitlab-ci","gitlab-ci-cd","gitlab-ci-pipeline","go"],"created_at":"2024-11-30T18:12:44.803Z","updated_at":"2026-05-08T13:46:51.751Z","avatar_url":"https://github.com/raojinlin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# env-from-mr\n\n`env-from-mr`是一个命令行工具，用于从GitLab Merge Request的描述中提取`env`代码块并其打印为导出环境变量的格式。可以在Merge Request中为Pipeline脚本动态地提供环境变量。\n\n## 安装\n\n你可以通过以下方式获取`env-from-mr`：\n\n```shell\ngo install github.com/raojinlin/env-from-mr\n```\n\n## 使用\nenv-from-mr 接受以下参数：\n\n- `mr-iid`：Merge Request的内部ID（如果没有指定，取CI_MERGE_REQUEST_IID环境变量）。\n- `pid`：GitLab项目的ID（必需）。\n- `token`：GitLab访问令牌（必需）。\n- `url`：GitLab的地址（必需）。\n\n示例:\n\n打印描述中的环境变量\n```bash\n$ env-from-mr -mr-iid 123 -pid 456 -token yourtoken -url yourgitlaburl\nexport ENV_A='a'\nexport SVC_A_HOST='localhost'\n```\n\n将描述中的环境变量导出\n```bash\n$ eval $(env-from-mr -mr-iid 123 -pid 456 -token yourtoken -url yourgitlaburl) \n$ echo $ENV_A\na\n$ echo $SVC_A_HOST\nlocalhost\n```\n\n\n在Pipeline中使用\n```yaml\npages-job:\n  stage: deploy\n  script:\n    - eval $(env-from-mr -mr-iid $CI_MERGE_REQUEST_IID -pid $CI_PROJECT_ID -url $CI_SERVER_URL -token yourtoken)\n    - echo $ENV_A\n    - echo $SVC_A_HOST\n```\n\n\n## 工作流程\n\n1. 获取指定Merge Request的描述。\n2. 在描述中查找env代码块并提取其中的环境变量内容。\n3. 使用eval命令导出提取的环境变量，可以在后续Pipeline步骤中使用。\n\n\n## 注意事项\n\n- 请确保你的GitLab访问令牌具有足够的权限来访问项目和Merge Request信息。\n- 该工具需要连接到GitLab的API，因此需要网络连接。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraojinlin%2Fenv-from-mr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraojinlin%2Fenv-from-mr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraojinlin%2Fenv-from-mr/lists"}