Use R Code or Windows User Variable ("%Userprofile%") in Yaml

Use R code or Windows user variable (%userprofile%) in YAML?

The problem is that the parameters in the output field is only understood by rmarkdown. Pandoc does not understand them, so you need to make sure rmarkdown can evaluate the expression. Since rmarkdown uses the yaml package to read the YAML metadata, and yaml's syntax for R expressions is !expr, you can put the R expression after !expr, e.g.

output:
word_document:
fig_caption: yes
fig_height: 4
fig_width: 7
reference_docx: !expr file.path(Sys.getenv('USERPROFILE'), 'Documents', 'template.docx')

How do I use the user home directory in a Github actions workflow that runs on Windows?

The answer is $HOME :

steps:
- name: Echo home
run:
echo $HOME

Log:

Run echo $HOME
C:\Users\runneradmin

How to set environment variables in Jenkins?

This can be done via EnvInject plugin in the following way:

  1. Create an "Execute shell" build step that runs:

    echo AOEU=$(echo aoeu) > propsfile
  2. Create an Inject environment variables build step and set "Properties File Path" to propsfile.

Note: This plugin is (mostly) not compatible with the Pipeline plugin.



Related Topics



Leave a reply



Submit