https://prefect.io logo
r

Ronald Sam

07/11/2023, 3:16 PM
hey guys, in the deployment pull step can I get the access token from a prefect block to authenticate with gitlab? https://docs.prefect.io/2.10.18/concepts/deployments-ux/#the-pull-action:~:text=Below%20is%20an%20exa[…]requirements.txt%20file%20after%20cloning%3A
c

Christopher Boyd

07/11/2023, 4:02 PM
You can store it as a secret, I’d need to check if gitlab credentials are supported yet
r

Ronald Sam

07/11/2023, 4:03 PM
Is secret the same as variable?
image.png
c

Christopher Boyd

07/11/2023, 4:03 PM
regarding your second question - that depends onwhat kind of infrastructure
yes
r

Ronald Sam

07/11/2023, 4:03 PM
thanks for getting back to me btw
c

Christopher Boyd

07/11/2023, 4:03 PM
A secret is a block type
r

Ronald Sam

07/11/2023, 4:03 PM
oh gotcha, I'll take a look
for the second question, what do you mean by it depends on kind of infra?
c

Christopher Boyd

07/11/2023, 4:04 PM
The short answer - previously, you could only load specifically prefect.block.secrets for the token, which was unintuitive if you had a gitlab credential or github credential
I think that was recently merged, but I don’t recall if that applied to all credential types
r

Ronald Sam

07/11/2023, 4:04 PM
thanks I'll try it out
c

Christopher Boyd

07/11/2023, 4:05 PM
The docs should now show using credentials fields in lieu of secrets
r

Ronald Sam

07/11/2023, 4:06 PM
oh very cool thank you
sorry @Christopher Boyd, one more question. Am I configuring this correctly in the pull step?
it's not working it's asking me to authenticate every time
however, if I did it myself with that access token, I'm able to clone my repo without issue, just doing it through prefect, it's not working. I think it's because it's not grabbing the credentials but not sure? Anyway I can see the url request it's sending to gitlab to see if it's correct?
c

Christopher Boyd

07/11/2023, 10:35 PM
If you could humor me and try as a secret instead of a credential:
Copy code
"{{ prefect.blocks.secret.<your secret here> }}"
r

Ronald Sam

07/11/2023, 10:35 PM
will do thank you
c

Christopher Boyd

07/11/2023, 10:35 PM
the credentials issue was one I reported, and only pretty recently merged in - I haven’t actually had the chance to test myself using the credentials so I couldn’t verify
If it’s a still an issue I can follow up on it; one other note, is that different SCM’s have different token requirements; for example when I tested using bitbucket, I had to set my token to literally like:
x-token-auth:<token>
or
<user>:<token>
so that was quite literally stored in the secret
r

Ronald Sam

07/11/2023, 10:39 PM
I'm getting this error after changing to secret
image.png
this is my pull step
what you suggested work, for gitlab it needs to be oauth2:<token>
i need to place that in the gitlab-credentials block
1
catjam 1
c

Chris Bui

07/24/2023, 2:21 PM
Hi I think i’m having a similar issue using version
2.11.0
. I’m able to get this to work using the
access_token
key but not
credentials
. Also, I can only get it to work using a secret block, not a gitlab-credentials block. Would you please confirm whether or not you’re seeing the same results? works:
Copy code
access_token: "{{ prefect.blocks.secret.gitlab-access-token }}"
doesn’t work:
Copy code
credentials: "{{ prefect.blocks.secret.gitlab-access-token }}"
credentials: "{{ prefect.blocks.gitlab-credentials.gitlab-credential }}"
c

Christopher Boyd

07/24/2023, 2:44 PM
Yo uneed to use a newer version
c

Chris Bui

07/24/2023, 3:35 PM
I was using version 2.11.0, which is the latest version right?
Copy code
prefect --version
08:33:04.337 | DEBUG   | prefect.profiles - Using profile 'dev'
2.11.0
c

Christopher Boyd

07/24/2023, 4:01 PM
Ah I missed that , for some reason I mistook what you posted - let me look closer
c

Chris Bui

07/24/2023, 4:04 PM
thank you!
e

Eldho Suresh

07/31/2023, 1:52 PM
Hi - I'm getting similar issue with git_clone and using gitlab credentials block. Tried both 2.11.0 and 2.11.1 version. It's also tricky to debug as it only returns an exit code which is generic. if we can log more details on error it would be much more easier. This is my flow run if that helps https://app.prefect.cloud/account/f6a834fb-85a2-4b18-9a99-21b9e534559f/workspace/2e7c[…]e0c1/flow-runs/flow-run/a4910da7-2db4-41c6-a1d2-774c50bd0fbb
@Christopher Boyd I've figured it out - for gitlab the token needs to be prefixed with
oauth2:
. Ronald has pointed this out above. Would help someone if we can add this info to doco
j

Jorge Severino

08/25/2023, 8:49 PM
"oauth2:" works for me. Thanks @Chris Bui
6 Views