BookmarkSubscribeRSS Feed
fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

@AhmedAl_Attar wrote:

I have a feeling your System Admins would need to install git on your SAS server before you could SAS's git functions  (gitfn_*)

Hi Ahmend!

Thank you for replying ... git is installed and available under /usr/bin/git (a unix system). But this seems to be messy ... as pointed out in this posting below. 
Hence the question if a dedicated OS version of git was needed to run git in SAS via the gitfn_* functions.

Cheers

 


 

yabwon
Onyx | Level 15

If the private repo is owned by your team (e.g. user MySuperTeamRepo) you could try to generate Private Access Token for a repo: 

https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure...

 

Settings:

https://github.com/settings/tokens

 

token type: classic

with the scopes: 

  • repo - Full control of private repositories
    repo:status - Access commit status
    repo_deployment - Access deployment status
    public_repo - Access public repositories
    repo:invite - Access repository invitations
    security_events - Read and write security events

and then:

 

filename x url 'https://raw.githubusercontent.com/MySuperTeamRepo/REPO_NAME/main/FILE_TO_INCLUDE.sas' 
user = 'MySuperTeamRepo' 
password = 'ghp_JKFGHKLDRF*********GHFKJDBVKJSDVJKHSDJK' /* <- token goes here */
/*debug*/
; %include x / source2;

 

You can parameterise it with macro variables:

[EDIT: semicolon was missing in macro definition]

%macro GetMeTheCode(
/* required */
 user
,token
,repoName
,file
/* optional */
,branch=main
,debug= /*debug*/
,source2= /*source2*/
);

filename x url "https://raw.githubusercontent.com/&user./&repoName./&branch./&file." 
user = "&user." 
password = "&token." /* <- token goes here */
&debug.
;
filename x list;

%include x / &source2.;

filename x clear;

%mend GetMeTheCode;


%GetMeTheCode(
 MySuperTeamRepo
,ghp_JKFGHKLDRF*********GHFKJDBVKJSDVJKHSDJK
,REPO_NAME
,FILE_TO_INCLUDE.sas
)

 

It's not a silver bullet since the token allows access to all repositories owned by MySuperTeamRepo, but maybe it will do the job for you.

 

All the best

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

If you decide to set up the "fine-grained token" with parameters:

Only select repositories: your selected repo

and

Repository permissions: Contents (Repository contents, commits, branches, downloads, releases, and merges.)  in Read_Only

that should give you some better "access" setup.

 

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

@yabwon wrote:

 

token type: classic

with the scopes: 

  • repo - Full control of private repositories
    repo:status - Access commit status
    repo_deployment - Access deployment status
    public_repo - Access public repositories
    repo:invite - Access repository invitations
    security_events - Read and write security events

and then:

 

filename x url 'https://raw.githubusercontent.com/MySuperTeamRepo/REPO_NAME/main/FILE_TO_INCLUDE.sas' 
user = 'MySuperTeamRepo' 
password = 'ghp_JKFGHKLDRF*********GHFKJDBVKJSDVJKHSDJK' /* <- token goes here */
/*debug*/
; %include x / source2;

 

Hello Bart!

Thank you for your reply. This is what I did when first trying it ... the filename line fails on me  with a timeout ... though the host is pingable.

Just that I am using (have to use) GitHup Enterprise.

Cheers

 

PS: And of course I did retry it with the code you suggested ... same result: timeout.

yabwon
Onyx | Level 15

Hmmm... 

 

I did a test with a "organisation" repo I have and it worked too. But "organiosation" repo it is not the same a "enterprise"... maybe some different setup is needed...

 

[EDIT:] maybe option: add a collaborator with read access only will do? but this will require that all possible users would have git account too...

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Another piece of information:

when using x command git clone  git clone https;//<MeName>:<MePwd>@<host>/<MeName>/<repo>.git on the sas host I get


Cloning into '<repo>'...
/usr/lib/git/git-remote-https: /opt/sas/sas94m7/SASHome/SASFoundation/9.4/sasexe/libcrypto.so.1.0.0: no version information available (required by /usr/lib64/libcurl.so.4)
/usr/lib/git/git-remote-https: /opt/sas/sas94m7/SASHome/SASFoundation/9.4/sasexe/libssl.so.1.0.0: no version information available (required by /usr/lib64/libcurl.so.4)
/usr/lib/git/git-remote-https: /opt/sas/sas94m7/SASHome/SASFoundation/9.4/sasexe/libcrypto.so.1.0.0: no version information available (required by /usr/lib64/libssh.so.4)
/usr/lib/git/git-remote-https: /opt/sas/sas94m7/SASHome/SASFoundation/9.4/sasexe/libssl.so.1.0.0: no version information available (required by /usr/lib64/libldap-2.4.so.2)
/usr/lib/git/git-remote-https: /opt/sas/sas94m7/SASHome/SASFoundation/9.4/sasexe/libcrypto.so.1.0.0: no version information available (required by /usr/lib64/libldap-2.4.so.2)
fatal: unable to access 'https://<host>/<MeName>/<repo>.git/': Failed to connect to <host> port 443 after 7247 ms: Couldn't connect to server

Funny/remarkable thing is: the unix git command (/usr/bin/git) draws the sas so-libs.


This seems to indicate that the git setup is messy on the host. EG however lets me clone it to the local PC, so the credentials seem to work.


AhmedAl_Attar
Ammonite | Level 13

@fja ,

The way I would debug this would be in isolation from SAS software - Native Linux/Unix approach:

1. Open a Terminal window connected to the SAS Linux server. You can do this via any SSH client software, alternatively you can use the SSH command from the windows CMD window

c:\> ssh <userID>@<SASServerName>

2. Once you logged into the SAS Server, at the prompt try to run the git clone command to test: 

- Ability to connect to external sites

(Some System Admins suppress this ability due to security mandates!

Others force you to use a Proxy server as a gateway to connect to external sites)

- Your credentials are permitted to connect/authenticate to the GitHub repository

3. Once the two above tests pass, then you try to do the same from within SAS using SAS's gitfn_* functions.

  

This way it should be clear where the issue is, rather than getting mixed signals 🙂

 

Hope this helps

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

@AhmedAl_Attar wrote:

[...]

Open a Terminal window connected to the SAS Linux server. You can do this via any SSH client software, alternatively you can use the SSH command from the windows CMD window

[...]

This way it should be clear where the issue is, rather than getting mixed signals 🙂

[...]

Hello Ahmed!

Thank you very much for your reply. You are all correct. But most unfortunately I do not have any access to the  server but through EG. So my attempt to use the X command is the closest thing to the approach you suggested. I have reported the results above.

Cheers

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

@ Bart: Thank you for indicating how it works on your side ... I guess this should be the solution I am looking for iff the git setup was correct. (see my posting above)

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 23 replies
  • 3811 views
  • 16 likes
  • 5 in conversation