Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crt key and get artifacts by path #302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thebravoman
Copy link

Crt and Key

In a Jenkins instance that is behind an https proxy the certificate might be restricted only to peers that have a certificate issued by the authority.
The jenkins_api_client should send the certificate issued by the authority with the call.

The purpose of the :crt and :key file arguments is to allow for the client to include its crt and key file when making the request and in this way authorizing to the https service.

Verify model

The certificate of the https service might be self-signed so I have added an option of ":verify_mode" that allows you to override the default verify_mode used to make the connections
In this way existing clients will not get a different behavior while new clients could specify their verify_mode

Example for calling with crt, key and verify_mode
```

    # This crt and key files could be generated with
    # openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys
    # openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes
    # This of course is only if you have p12 file.
    JenkinsApi::Client.new(:server_url=>the_url,
                           crt: the_crt,
                           key: the_key,
                           ssl: true,
                           verify_mode: OpenSSL::SSL::VERIFY_NONE,
                           :username=>ENV["JENKINS_USERNAME"],
                           :password=>ENV["JENKINS_PASSWORD"])
```

get_artifact_by_path

Sometime you need to get not all the artifacts but a specific artifact. This new method allows you to.
This is need when the build produces to many artifacts and you only want to download one of them as you only need one of them.

kireto added 2 commits October 15, 2020 00:24
…en sending a post for a build.

The post will include the same cookie
1. Crk and Key
In a jenkins instance that is behind an https proxy the certificate might be restricted only to peers that have a certificate issued by the authority.
The jenkins_api_client should send the certificate issued by the authority with the call.

The perpose of the :crt and :key file arguments is to allow for the client to include its crt and key file when making the request and in this way authorizing to the https service.

2. Verify model
The certificate of the https service might be self-signed so I have added an option of ":verify_mode" that allows you to override the default verify_mode used to make the connections
In this way existing clients will not get a different behaviour while new clients could specify their verify_mode

Example for calling with crt, key and verify_mode
```

    # This crt and key files could be generated with
    # openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys
    # openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes
    # This of course is only if you have p12 file.
    JenkinsApi::Client.new(:server_url=>the_url,
                           crt: the_crt,
                           key: the_key,
                           ssl: true,
                           verify_mode: OpenSSL::SSL::VERIFY_NONE,
                           :username=>ENV["JENKINS_USERNAME"],
                           :password=>ENV["JENKINS_PASSWORD"])
```

3. get_artifcat_by_path

Sometime you need to get not all the artifacts but a specific artifact. This new method allows you to.
This is need when the build produces to many artifacts and you only want to download one of them as you only need one of them.
Copy link
Collaborator

@grosser grosser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks neat, can you add some basic unit tests ?

@grosser
Copy link
Collaborator

grosser commented Mar 20, 2023

(and rebase so CI runs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants