Jenkinsfile inline checkout of a repo using ssh deploy keys possible? - github

I was checking out a repo inline in the Jenkinsfile like the below and installing/running :
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '../myRepoFolder']], userRemoteConfigs: [[credentialsId: '92312d0c-12301230-12931293-f92124', url: 'https://github.com/MyOrg/my-repo']]])
container('node') {
dir('../myRepoFolder'){
//run some command on folder - npm ci, npm start etc...
}
}
This was working fine for a while, but then we switched from using standard authentication with https git url to ssh auth with deploy keys - so the above inline checkout no longer works
I have a Jenkins credential (deploy-key) setup with my private key setup w/ my-repo. How can I modify the Jenkins checkout() command to use ssh to checkout my repo in the same way I have above?

Use SSH credentials and SSH URL:
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '../myRepoFolder']], userRemoteConfigs: [[credentialsId: '<gitSshCredentials>', url: '<gitRepoSshURL>']]])

Related

How to Upload apple_secret_key.p8 to deployment Environment

I am setting up Apple Login in a nestjs backend application and the application is live on render.com using github codepipeline.
I have completed the Apple Login configuration, and I want to push it to github so that render can update the deployment; however, there is a folder apple_secret that contains my apple_secret_key.p8 in the root directory that I am pointing to in my AppleStrategy configuration that I don't think is safe for me to push to github.
constructor(configService: ConfigService) {
super({
clientID: configService.get<string>('APPLE_CLIENT_ID'),
teamID: configService.get<string>('APPLE_TEAM_ID'),
keyID: configService.get<string>('APPLE_KEY_ID'),
key: readFileSync(
__dirname + '/../../../apple_secret/apple_secret_key.p8',
),
callbackURL: configService.get<string>('APPLE_CALLBACK_URL'),
scope: ['name', 'email'],
});
}
How do I make this folder and the content (apple_secret/apple_secret_key.p8) available for render.com to read?

Nuxtjs - Error 404 with post request in production while working in local

I'm actually trying to use nuxt-mail in a personnal project,
During my development phase, I receive all my testing mails. And from there I did the following adjustments to do the exact same request from my builded site :
//nuxt.config.js
env: {
baseUrl:
process.env.NODE_ENV === 'dev'
? 'http://localhost:3000'
: 'https://my-domain.netlify.app'
},
My code when using the 'send' function :
this.$axios.$post(process.env.baseUrl + "/mail/send", {
config: 'contact',
from: document.getElementById('input-2').value,
subject: document.getElementById('subject').value,
text: "This is a text message",
})
It continues to work well with localhost/3000/mail/send but I have a 404 error once I build my site and using https:/ /my-domain.netlify.app/mail/send :
POST https://my-domain.netlify.app/mail/send [HTTP/2 404 Not Found 186ms]
Uncaught (in promise) Error: Request failed with status code 404
I'm actually struggling to solve this problem, am I missing something ?
Alright, so if your target is static, you can only do yarn generate.
If you do have the default, aka target: server, you can only yarn build.
Then, as talked about it a bit here: Sending mail in Nuxt.js with nuxt-mail
You cannot use a Node.js package in a static environment, so neither yarn generate nor Netlify will help you here. You need to yarn build and host it on something like Heroku.
One last step that you can do, is to try it locally with the following:
target: server
yarn build
yarn start
make your POST call with Postman or alike
If it does not work here, it is a code issue and you can look into the hosting one.
If it does work locally, you can proceed to the hosting issue that you'll face.
Well you just misunderstood the env field in the nuxt.config.js file.
That env field is passed to the $config Object of the Nuxt App and not passed to process.env.
What you want is to set the BaseUrl for the Axios Module
// nuxt.config.js
axios: {
baseURL: process.env.NODE_ENV === 'dev'
? 'http://localhost:3000'
: 'https://my-domain.netlify.app'
},
// or provide a runtime config
// server and clientside
publicRuntimeConfig: {
axios: {
browserBaseURL: process.env.BROWSER_BASE_URL
}
},
// serverside only
privateRuntimeConfig: {
axios: {
baseURL: process.env.BASE_URL
}
},
Edit:
Also when calling axios just do it like that if you implement the above changes
this.$axios.$post("/mail/send", {
// ... the rest of your code

Spring cloud config - Remote hung up unexpectedly

I am trying to connect to private gitlab self hosted service with ssh key.
Following is the yaml config
spring:
cloud:
config:
server:
git:
uri: git#gitlab.devops.mhealth.tech:shivhg/config_src.git
ignoreLocalSshSettings: true
host-key: shiva.kumar#mhealth.tech
strictHostKeyChecking: false
hostKey: someHostKey
hostKeyAlgorithm: ssh-rsa
privateKey: |
Also tried .ssh/config update
StrictHostKeyChecking no
PreferredAuthentications publickey
IdentitiesOnly yes
IdentityFile ~/.ssh/***private
ServerAliveInterval 60
ServerAliveCountMax 5
Receiving exact same error as #1447 tried the suggestions provided there as well.
Tried in intellij also in iterm console.
Some pointers to fixing this would be helpful, thanks in advance

JHipster Registry How to config git username and password

I am trying to set up the JHipster Registry with a local git config server.
--spring.cloud.config.server.composite.0.type=git
--spring.cloud.config.server.composite.0.uri=http://mygit/abc.git
those 2 config works but my git need permission to login.
now I got the error: Authentication is required but no CredentialsProvider has been registered
Does anyone know where can I set up the username and password?
I tried:
--spring.cloud.config.server.git.uri=
--spring.cloud.config.server.git.password=
--spring.cloud.config.server.git.username=
not working
Try
--spring.cloud.config.server.composite.0.username=
--spring.cloud.config.server.composite.0.password=
Add the following in the bootstrap-*.yml
cloud:
config:
server:
bootstrap: true
composite:
- type: git
uri: https://github.com/awnali/configuration
username: ${spring.cloud.config.server.git.username}
password: ${spring.cloud.config.server.git.password}
default-label: main
and then run the application with the following command:
java -jar target/jhipster-registry-6.8.0.jar --spring.profiles.active=prod --spring.cloud.config.server.git.username=***** --spring.cloud.config.server.git.password=*****

How to configure github with proxy?

I am running through a proxy and i do not understand how to make git work.If i try to clone a repo i get the following error:
$ git clone https://github.com/somerepo
Cloning into '[something]'... fatal: unable to access
'https://github.com/somerepo': OpenSSL SSL_connect:
SSL_ERROR_SYSCALL in connection to github.com:443
I have already tried most of what it is saying here changing the git global and checked this SO thread too to no avail.
I have also tried to unset proxy for http and https.
Looking in my git config it looks like this:
[user]
name = Adri
email = [some_address]#outlook.com
[http]
sslBackend = openssl
sslCAInfo = C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem
[remote "origin"]
proxy =
Could this be a problem ?
P.S I get this problem for all git operations, i can't clone,pull,push etc.. and for all repositories.