How Do You Invoke a Function in Groovy?

Problem scenario
You want to call a function and have it return a value. How do you do this?

Solution
Overview
(If you need assistance installing Groovy, see this posting for CentOS. or see this posting for Debian/Ubuntu Linux.)

Groovy has something called “Closures.” These act like functions in other programming languages.

 » Read more..

How Do You Deactivate a HipChat User with Only His/Her Email Address Using the REST API?

Problem scenario
You have email addresses of users that you want deactivated. You do not want to use the GUI for HipChat. How do you invoke REST APIs to deactivate a user?

Prerequisite
You need an API token for HipChat. If you have this, start with the Procedures below. Otherwise keep reading this “Prerequisite” section. You need several scopes for the API token authorize you to be able to deactivate a user.

 » Read more..

How Do You Install Docker on Debian Linux in GCP?

Problem scneario
In Google Cloud Platform you have a Debian Linux server. You want to install Docker on it. What do you do?

Solution
1. Create a file called dockerinstall.sh in the /tmp/ directory with the following content:

apt-get -y update
apt-get install -y apt-transport-https ca-certificates wget software-properties-common

wget https://download.docker.com/linux/debian/gpg
apt-key add gpg

echo “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee -a /etc/apt/sources.list.d/docker.list
apt-get -y update

apt-get -y install docker-ce

2.

 » Read more..

How Do You Create a Dockerfile That Will Use Reserved Words Such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL?

Problem scenario
You want to create your own Dockerfile. You also want to invoke reserved words such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL. You want to then create a Docker image from it. You want to ultimately create a working Docker container from that image. How do you do all of this?

Solution

1. In a given directory, create a file called extra.txt.

 » Read more..

How Do You Troubleshoot the Error “Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.sun:tools:jar:1.8.0”?

Problem scenario
You run a Maven command but you get this:

“Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.sun:tools:jar:1.8.0 at specified path /usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar:

You are running Ubuntu or Debian Linux. What should you do?

Solution
Run this: sudo apt install default-jdk

 » Read more..

How Do You Change the Indentation of the GUI-Rendering of a File in Bitbucket?

Problem scenario
You are using a web browser and some items in a list are indenting where you do not want them indented. How do you make them line up with the other items in the list without indentation?

Solution
Bitbucket’s rendering of a text file does an auto-indent for natural numbers (with no sub-numbering scheme). If you have this in a file,

 » Read more..

How Do You Troubleshoot the Maven Error “Malformed POM…Unrecognised tag: ‘dependency'”?

Problem scenario
You run a Maven (mvn) command. But you receive an error like this:

[INFO] Scanning for projects…
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /home/jdoe/b/gs-maven/initial/src/pom.xml: Unrecognised tag: ‘dependency’ (position: START_TAG seen …\n \n \n … @17:17) @ /home/jdoe/b/gs-maven/initial/src/pom.xml, line 17, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.springframework:gs-maven:0.1.0 (/home/jdoe/b/gs-maven/initial/src/pom.xml) has 1 error
[ERROR] Malformed POM /home/jdoe/b/gs-maven/initial/src/pom.xml: Unrecognised tag: ‘dependency’ (position: START_TAG seen …\n \n \n … @17:17) @ /home/jdoe/b/gs-maven/initial/src/pom.xml,  » Read more..

How Do You Get around The AccessDeniedException Error with SonarQube?

Problem scenario
You are trying to set up SonarQube for the first time. You run this command:

bash /opt/sonarqube/bin/linux-x86-64/sonar.sh console

You see this error:

“jvm 1 | java.nio.file.AccessDeniedException: /opt/sonarqube/temp/conf/es/elasticsearch.yml”

What do you do?

Solution
Make sure that the user who is running the command has the ability to execute files in the /opt/sonarqube/ directory (or wherever the destination is that you are installing Sonarqube).

 » Read more..

How Do You Troubleshoot the Google Kubernetes Engine error “Request had insufficient authentication scopes”?

Problem scenario
You run a command like this:
gcloud container clusters get-credentials standard-cluster-1 –region us-central1-a

But you receive this message:
“Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Request had insufficient authentication scopes.”

What should you do?

Solution
1. Stop the VM.
2. Click on the hyperlinked name of the VM.
3.

 » Read more..

How Do You Verify the Jenkins Credentials Plugin Username and Password Are Correct and in the Right Syntax?

Problem Scenario
You are using Jenkins and its Credentials plugin. You are not sure if the syntax of the username and password are correct. You think that there may be a wrong username or password. You want to see how things look as they are used in a pipeline job. The console output shows the credentials as “****”. What should you do?

Solution
Warning: this is not a recommended practice.

 » Read more..