Skip to content

Instantly share code, notes, and snippets.

@prem0132
Last active June 3, 2021 04:25
Show Gist options
  • Save prem0132/cdcfe8e6f5241650e727bbe2b41429eb to your computer and use it in GitHub Desktop.
Save prem0132/cdcfe8e6f5241650e727bbe2b41429eb to your computer and use it in GitHub Desktop.
migrate gitlab vars
import gitlab
gl = gitlab.Gitlab('https://gitlab.com', private_token='************')
src_project = gl.projects.get('1111111')
dst_project = gl.groups.get('22222222')
variables = src_project.variables.list(all=True)
for variable in variables:
attrs=variable.__dict__
var=attrs["_attrs"]
d_var=dst_project.variables.create(var)
d_var.save()
variables = dst_project.variables.list(all=True)
print("\n\n\n\n",variables)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment