Skip to content

Instantly share code, notes, and snippets.

@klauszhang
Last active July 31, 2019 01:13
Show Gist options
  • Save klauszhang/1ad32faaf5b7177a16a684836cf08282 to your computer and use it in GitHub Desktop.
Save klauszhang/1ad32faaf5b7177a16a684836cf08282 to your computer and use it in GitHub Desktop.
Migrate gitlab variables
// read value
JSON.stringify(
[...document.getElementsByClassName('js-row')].map(el => {
const key = el.querySelector('.js-ci-variable-input-key').value
const { value } = el.querySelector('textarea.js-ci-variable-input-value')
return [key, value]
})
)
const result=[[]] //whatever from last step
// write value from last step (you need to create rows fist)
result.forEach((setting, index) => {
document.querySelectorAll('.js-row .js-ci-variable-input-key')[index].value =
setting[0]
document.querySelectorAll('.js-row textarea.js-ci-variable-input-value')[
index
].value = setting[1]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment