Rundeck Groovy Notification Plugin using Key Storage? - groovy

I'm trying to create a Groovy Notification plugin for Rundeck that has one property called webhook_url, which is stored in Key Storage. When adding the plugin to a job's notification config, it should have you choose the entry in Key Storage and it'll substitute that key's value. I can get the rendering option to allow you to choose a key, however it substitutes the path to the key rather than the value it holds. It does not like my valueConversion parm in Groovy. Is this because I'm doing it wrong, or because Groovy Notification plugins don't support STORAGE_PATH_AUTOMATIC_READ?
Below is my config:
configuration{
webhook_url title:"Webhook URL", required: true, type:"String", description:"dummy", renderingOptions:[valueConversion:StringRenderingConstants.ValueConversion.STORAGE_PATH_AUTOMATIC_READ, selectionAccessor:StringRenderingConstants.SelectionAccessor.STORAGE_PATH]
}
Thanks in advance.

No supported right now, you can suggest it here. It's accesible on Java/Groovy compiled plugins.

Related

Access secret environment properties in IBM cloud deploy - NodeJS

I'm having some problem with accessing my secret environments properties I've set in my build stage. In the build environment properties I got two secret fields called "w_username" and "w_password", however, I can not access these properties inside of my NodeJS runtime. I've tried with process.env['w_username'] but it seems like it can't find it. How is it possible to access them?
Using NodeJS 6.x, npm 6.x with SDK for NodeJS on IBM cloud.
You can directly access the build environment properties in the next stage in the toolchain with their names like w_username and w_password.
You can examine the environment properties for a pipeline job by
running the env command in the job's script.
You can also define your own environment properties. For example, you might define an API_KEY property that passes an API key that is used to access IBM Cloud resources by all scripts in the pipeline.
You can add the following types of properties:
Text: A property key with a single-line value.
Text Area: A property key with a multi-line value.
Secure: A property key with a single-line value that is secured with AES-128 encryption. The value is displayed as asterisks.
Properties: A file in the project's
repository. This file can contain multiple properties. Each property
must be on its own line. To separate key-value pairs, use the equals
sign (=). Enclose all string values in quotation marks. For example,
MY_STRING="SOME STRING VALUE".
For more information, refer here
Hope this helps

Does chrome.storage.managed policy work for self-hosted extensions?

I am trying to configure an extension using the method described at Manifest for storage areas
. I'm pretty sure I have everything set up correctly, but I am not seeing the policy value in chrome://policy(it is shown as Not set) and, obviously, there is no policy seen from
chrome.storage.managed.get(null,(d)=>{console.log(d)});
I've checked my schema and the config file I uploaded in the Admin Panel at https://www.jsonschemavalidator.net and it seems to match. It's very simple, schema.json is
{
"type" : "object",
"properties" : {
"PolicyTest" : {
"type" : "string"
}
}
}
and in the json file
{
"PolicyTest" : "test"
}
Before I spend a bunch of time debugging this, I thought I would quickly ask- could this be because the extension that I am configuring this for is not hosted on the Chrome Web Store? It's hosted myself using the method described at Autoupdating.
Other than that, I'm not really sure why this isn't working- the device running Chrome is Linux, although I have also checked on a managed Chromebook, and I've checked things like making sure I've selected the right OU, refreshing the policy, and so on.
Ok, I figured it out by reference to the Chromium documentation. To answer the question in my title- yes, it works fine for extensions not hosted on the Web Store, I just had the wrong format for my options.
Basically, my json file didn't actually match the schema. For the schema I posted in my question, you actually need this :
{
"PolicyTest" : {
"Value" : "test"
}
}
Basically, your properties need to be an object with a Value field. The core sentence that I missed is : The txt file should contain a valid JSON object, mapping a policy name to an object describing the policy.
Mea cupla, I should have read the documentation more carefully. It's quite frustrating that the official Chrome extension developer documentation doesn't have a simple example of a schema and a matching config file, since there is no UI feedback if your format is wrong.
I note also there was some plan to publish a tool to build a template from a schema. I guess that never happened, it would be useful too.

cannot read property 'client_secret' of undefined

I have tried to create a sample program using Node.js, following instructions from https://developers.google.com/google-apps/activity/v1/quickstart/nodejs
I throws an error saying cannot read property 'client_secret' of undefined when trying to run it.
Looking for your valuable suggestions.
Thanks in advance.
var clientSecret = credentials.installed.client_secret;
In this line credentials is pointing to client_secret.json so the first key has to be "installed". In my case the key was "web" and that was causing the error. I just renamed the key "web" to "installed".
Since there is no key named "installed", it's parsing it to be undefined.
In credentials.json change the key "web" to "installed". Probably the docs need to change from Google's side.
Before
After
It seems you have missed Step 1: Turn on the Google Apps Activity API.
After creating the Credentials:
f. Click the file_download (Download JSON) button to the right of the
client ID.
g. Move this file to your working directory and rename it
client_secret.json. Put it in your project folder.
Your client_secret.json file needs to have the line below:
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]
instead of the lines like below:
"javascript_origins":
[
"http://localhost:8080",
"http://localhost:1453",
"http://127.0.0.1:1453",
"http://localhost"
]
Also you may want to change chain head in client_secret.json from web to installed, or vise versa.
I had this problem, but I had the wrong type of credentials file. I initially used "Web Server (Nodejs)...", and it had the "web" heading instead of the "installed", but when I did it again, and selected "Windows UI (cmd line)", I got the file with the correct format.
Try selecting the application type "Other".
Select the "Help me choose" option and there you can chose other application type.
That way your client_secret.json will have the variable named "installed".
The recent version of Google Drive API will have a Desktop client option while creating OAuth API Key. Do select that, it will have all required information to access Google drive from Script.

SendGrid API Key is not working. "The provided authorization grant is invalid, expired or revoked"

SendGrid seems to be preventing my node js server from sending emails.
I get this error message in the response on sending off an email:
The provided authorization grant is invalid, expired or revoked
I have an API key setup as well and have followed the documentation.
You need to use the API KEY GENERATED
DO NOT USE the API KEY ID
Sendgrid only displays the generated key once when you create it.
If you didn't record it somewhere when you created the key you'll need to create a new key and then you'll probably want to delete the old key since it would be useless if you don't know what it is.
FYI: The API key in the screenshot above is already deleted. I deleted it right away so please don't worry about me leaking that key.
This is a late answer and JAVA oriented.. But I simply copied the docs and didn't notice..
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
I just put my key in there and didn't see the getEnv. Silly of course.. but when trying to get things to work quickly...
For me I just had to generate a new API key. For some weird reason the former API key has become invalid, so I also added an alert for this case
In Sendgrid v3, I had the similar issue when using env variable in Node JS. If I use env variable, I get the above issue. But if I drop the string into the require process, it works.
Doesn't Work:
SENDGRID_API_KEY=SG.XXXXXXXXXXXXXXXXXXX
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
Works
var sg = require('sendgrid')('SG.XXXXXXXXXXXXXXXXXXX');
Replace SG.XXXXXXXXXXXXXXXXXXX with API Key Generated (which you can only see once during key generation).
EDIT
Note : Make sure you don't save this to public repository. If you do anyone can use your API Key and also your account will be suspended by Sendgrid team temporarily until you remove it from repository.
In my case I was trying to debug the connection by using telnet and kept getting rejected.
Turns out that these two are not equivalent, echo will include \n in the encoded string.
echo 'apikey' | base64
printf 'apikey' | base64
So yeah, make sure you don't include the newline in the API key.
If you are using node js,
make sure you have the require('dotenv').config()line inside the file that needs the sendgrid/nodemailer module.
Without it, the sendgrid transporter will have an undefined value instead of the api_key.
Here's my solution:
Install the dotenv package: npm i dotenv
Go to the earliest entry point of your application(i.e index.js) and put this at the top:
const dotenv = require('dotenv').config();
Create a .env file and add SENDGRID_API_KEY=<YOUR_API_KEY>. NO quotes '' or "".
In your file which you use sendgrid, add this to the top:
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
Done.
It might be late for an answer but for people who are getting the same problem in spring boot
it might be caused at initialization when you are using env or property value
i was initializing the variable in the constructor before the value was loaded by spring and it was giving the same output. so either initialize it in the method you are calling the SendGrid function or do it after values are loaded
Instead of using,
api_key: ${process.env.SENDGRIDAPIKEY}
try,
api_key: "" + ${process.env.SENDGRIDAPIKEY} + ""
worked for me,
For me; I've just created a new API key and then it works again.
I'm %100 sure it was working with no any code change.
Maybe it is an issue with SendGrid or some sort of security action from SendGrid.
I had the same issue, it disappeared after I verified my email address and enabled 2FA.

jenkins: setting root url via Groovy API

I'm trying to update Jenkins' root URL via the Groovy API, so I can script the deployment of a Jenkins master without manual input (aside: why is a tool as popular with the build/devops/automation community as Jenkins so resistant to automation?)
Based on this documentation, I believe I should be able to update the URL using the following script in the Script Console.
import jenkins.model.JenkinsLocationConfiguration
jlc = new jenkins.model.JenkinsLocationConfiguration()
jlc.setUrl("http://jenkins.my-org.com:8080/")
println(jlc.getUrl())
Briefly, this instantiates a JenkinsLocationConfiguration object; calls the setter setUrl with the desired value, http://jenkins.my-org.com:8080/; and prints out the new URL to confirm that it has changed.
The println statement prints what I expect it to, but following this, the value visible through the web interface at "Manage Jenkins" -> "Configure System" -> "Jenkins URL" has not updated as I expected.
I'm concerned that the value hasn't been update properly by Jenkins, which might lead to problems when communicating with external APIs.
Is this a valid way to fix the Jenkins root URL? If not, what is? Otherwise, why isn't the change being reflected in the config page?
You are creating a new JenkinsLocationConfiguration object, and updating the new one, not the existing one being used
use
jlc = JenkinsLocationConfiguration.get()
// ...
jlc.save()
to get the one from the global jenkins configuration, update it and save the config descriptor back.
see : https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java

Resources