jenkins Could not set the value of environment variable 'BUILD_USER' - jenkins

i'm using jenkins to build android project,
however i always got below error: "* What went wrong:Could not set the value of environment variable 'BUILD_USER': could not convert string to current locale"
i don't know where is environment variable 'BUILD_USER',i am confused why could not set it. can anyone please help?

BUILD_USER comes from the Build User Vars plugin. It should be the First and Last name of the user who triggered the build (as defined in the Security Realm, i.e. LDAP, internal DB, etc.).
I am guessing that there is some character in the name of the user that doesn't agree with the locale configured in your Jenkins environment. You could disabled that plugin (remove the checkbox next to it in the "Manage Plugins" page), and see if the error goes away. Then you can troubleshoot from there.

Related

How to select password from dropdown and pass it as parameter to jenkins job?

I have a problem. I use Jenkins to deploy application on machines. Depending on which machine i want to deploy new version I need to use different database passwords to run db migrations. I want to store credentials in Jenkins and for each deploy job select credentials set from dropdown which will be passed (just password ) to powershell script. I have Credentials Binding Plugin and Extended Choice Parameter Plugin. I thought it might help me with my problem, but I cannot find solution for this. Do you have any ideas how to achieve this?
As I understand, you need only to do two things:
add Credential Parameter in This project is parameterized section for possibility to select credentials set from dropdown.
enable Use secret text(s) or file(s) option in Build Environment section. This will allow you to take credentials of various sorts and use them from shell build steps and the like. Each binding will define an environment variable.
If you have already created Jenkins credentials like these:
then you will be available to run your job using Build with Parameters button and select needed credentials:
So, after configuring, you don't need to dig in job configuration each time, all possible credentials will be automatically loaded, you need only select the needed one when run a job.

Does Jenkins have a feature like credentials for non-secrets?

real simple question today.
Does Jenkins have a feature like credentials that is for non-secret information?
My use case is that I want to specify some values in jenkins to make them easily available to all of my pipelines. (e.g. an Azure subscription id) I tried to just use 'secret text' type credentials, but the magic that jenkins does to protect those credentials make it difficult to work with them.
I imagine it would be called something like global environment variables, or named values, but I haven't been able to find anything with my googling.
Thanks!
The following steps will help you setup global environment variables which can be used within various builds and pipelines. The steps may be slightly different based on the version of Jenkins installed. The steps noted below are based on version 2.7.4:
Navigate to Manage Jenkins on the left side menu
Click "Configure System"
Scroll down to find "Global properties"
Check "Environment variables"
Click "Add"
Add the name and value in correct input area (Example: arg_name & arg_value)
Click "Save" at the bottom of the page
To use this global environment variable, navigate to an input area within a build definition and use: ${arg_name}

Use jenkins to inject masked password for use in code within the build

My aim:
To use a password in jenkins which is masked after input and runtime.
I only need it for my job.
I can use it in my java code to login to a website.
Areas I have looked at:
The credentials plugin - this looks like the right area (but I'll need to get the sysadmins to add me as its locked down).
Also I can't find out how you can access the output?
Have a look into the EnvInject plugin, there you can define password parameters that are masked in console output and job configuration, they can be used like normal parameters.
The screenshot shows the configuration in the job to use a local password.
The shell script build step I used is
echo "myPassword = $myPassword"
The resulting console output is:
+ echo 'myPassword = [*******]'
myPassword = [*******]
To pass it to Java you can use it like any other parameter from the job configuration. The value itself is encrypted, so checking the job configuration as XML will not reveal the password either.
You can use the jenkins credentials binding plugin.
After installing the Credentials Bindings plugin, the Build Environment section of your build job Configuration page will include a new option:
Use secret text(s) or file(s)
Enabling this option allows you add credential bindings where the Variable value will be used as the name of the environment variable that your build can use to access the value of the credential.
See the full description of all steps here:
https://support.cloudbees.com/hc/en-us/articles/203802500-Injecting-Secrets-into-Jenkins-Build-Jobs

How to use the 'Issue attribute path' in the parameter mapping of jenkins-trigger-plugin

I am willing to trigger my Jenkins job based on status change event from a JIRA issue. I am able to do it using jenkins-trigger-plugin. However I wish to get some more information about the issue like the description of the issue etc. I could see an environment variable named 'JIRA_ISSUE_KEY' but it gives me the key and nothing else.
As of the current release, the issue attribute path is currently resolved from this Issue object. All of jira-trigger-plugin configuration is documented in Jenkins help buttons, which is viewable in Jenkins job configuration.
description for example is retrievable via description path (which would call issue.getDescription() essentially).

Using environment variables with Jenkins

I'm building a group of projects from the SVN. There is a possibility of changing the SVN location time to time. As there are bunch of projects I hope to give the repository url with a environment variable so i can change all the url's easily. Any idea how to do that??
In Subversion Source Code Management, you can use variable in the Repository URL, simply type:
http://my.svn.com/path/to/${VARIABLE}
${VARIABLE} is a job parameters that is defined earlier. Never heard of anyone wanting to use actual environment variables for this, but you can try with the same syntax.
By default, it will give you a red warning that this is not a valid URL. You can disable this warning by going to Manage Jenkins -> Configure System and look for Validate repository URLs up to the first variable name. Put a checkmark there and save.

Resources