英文:
How to use env from reusable workflow in main pipeline?
问题
I have a reusable workflow where I have sent one value via env
like below:
- name: 'reusable_workflow'
run : |
echo "value=$variable_name" >> $GITHUB_ENV
Now, I need to use the same value in my main pipeline. How can I achieve this?
Below is the main pipeline where I need to use value
:
- name: 'main_pipeline'
run: |
echo "${{ env.value }}"
Both are the separate workflows and repos are different.
英文:
I have a reusable workflow where I have sent one value via env
like below:
- name: 'reusable_workflow'
run : |
echo "value=$variable_name" >> $GITHUB_ENV
Now, I need to use the same value in my main pipeline. How can I achieve this?
Below is the main pipeline where I need to use value
:
- name: 'main_pipeline'
run: |
echo "${{ env.value }}"
Both are the separate workflows and repos are different.
答案1
得分: 1
> 在调用者工作流程中定义的env
上下文中设置的任何环境变量不会传播到被调用的工作流程。
> 同样,在被调用的工作流程中定义的env
上下文中设置的环境变量不可在调用者工作流程的env
上下文中访问。相反,您必须使用可重用工作流程的输出。
> 可重用工作流程直接在作业中调用,而不是在作业步骤中调用。因此,您不能使用GITHUB_ENV
将值传递给调用者工作流程中的作业步骤。
请参阅使用可重用工作流程的输出以共享可重用工作流程的值。
英文:
According to the Limitations of Reusing workflows:
> Any environment variables set in an env
context defined at the workflow level in the caller workflow are not propagated to the called workflow.
and,
> Similarly, environment variables set in the env
context, defined in the called workflow, are not accessible in the env
context of the caller workflow. Instead, you must use outputs of the reusable workflow.
also,
> Reusable workflows are called directly within a job, and not from within a job step. You cannot, therefore, use GITHUB_ENV
to pass values to job steps in the caller workflow.
See Using outputs from a reusable workflow to share values from the reusable workflow.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论