Last active
August 21, 2019 12:09
-
-
Save loopmode/4515b4d9b2de88ada49d807e9b14d10e to your computer and use it in GitHub Desktop.
printing Gitlab CI/CD variables as key/value pairs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function getGitlabSecrets() { | |
const secrets = [ | |
...document.querySelectorAll('.ci-variable-row-body'), | |
].reduce((result, row) => { | |
const key = row.querySelector( | |
'[name="variables[variables_attributes][][key]"]', | |
).value; | |
const value = row.querySelector( | |
'[name="variables[variables_attributes][][secret_value]"]', | |
).value; | |
if (key) { | |
Object.assign(result, { [key]: value }); | |
} | |
return result; | |
}, {}); | |
return secrets; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function showGitlabSecrets() { | |
const secrets = [ | |
...document.querySelectorAll('.ci-variable-row-body'), | |
].reduce((result, row) => { | |
const key = row.querySelector( | |
'[name="variables[variables_attributes][][key]"]', | |
).value; | |
const value = row.querySelector( | |
'[name="variables[variables_attributes][][secret_value]"]', | |
).value; | |
if (key) { | |
result.push(`${key}=${value.split('\n').join('\\\n')}`); | |
} | |
return result; | |
}, []); | |
const el = document.createElement('pre'); | |
el.innerHTML = secrets.join('\n'); | |
document.getElementById('content-body').prepend(el); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function showGitlabSecretsJSON() { | |
const secrets = [ | |
...document.querySelectorAll('.ci-variable-row-body'), | |
].reduce((result, row) => { | |
const key = row.querySelector( | |
'[name="variables[variables_attributes][][key]"]', | |
).value; | |
const value = row.querySelector( | |
'[name="variables[variables_attributes][][secret_value]"]', | |
).value; | |
if (key) { | |
Object.assign(result, { [key]: value }); | |
} | |
return result; | |
}, {}); | |
const el = document.createElement('pre'); | |
el.innerHTML = JSON.stringify(secrets, null, 2); | |
document.getElementById('content-body').prepend(el); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment