Last active
March 20, 2020 00:24
-
-
Save marcelaraujo/1480f83532ecd54d46ea1f69c3ce5ef9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.cloudbees.plugins.credentials.*; | |
| import com.cloudbees.plugins.credentials.domains.Domain; | |
| import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl; | |
| def secret = '''Hi | |
| there, | |
| only | |
| test''' | |
| def secretBytes = SecretBytes.fromBytes(secret.getBytes()) | |
| def credentials = new FileCredentialsImpl(CredentialsScope.GLOBAL, 'my test file', 'description', 'file.txt', secretBytes) | |
| SystemCredentialsProvider.instance.store.addCredentials(Domain.global(), credentials) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.cloudbees.plugins.credentials.*; | |
| import com.cloudbees.plugins.credentials.domains.Domain; | |
| import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl; | |
| import java.nio.file.*; | |
| Path fileLocation = Paths.get("/path/to/some/file.txt"); | |
| def secretBytes = SecretBytes.fromBytes(Files.readAllBytes(fileLocation)) | |
| def credentials = new FileCredentialsImpl(CredentialsScope.GLOBAL, 'my test file', 'description', 'file.txt', secretBytes) | |
| SystemCredentialsProvider.instance.store.addCredentials(Domain.global(), credentials) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment