Skip to content

Instantly share code, notes, and snippets.

View baymac's full-sized avatar
👋

Parichay Barpanda baymac

👋
View GitHub Profile
@baymac
baymac / gitlab-job-dsl.groovy
Last active December 8, 2022 16:43
A sample job dsl configuration of gitlab folder organisation
private boolean isSandbox() {
def locationConfig = jenkins.model.JenkinsLocationConfiguration.get()
if (locationConfig != null && locationConfig.getUrl() != null) {
locationConfig.getUrl().contains("staging")
} else {
System.getenv("ENVIRONMENT") == "sandbox"
}
}
List<Map> gitlab = []
@baymac
baymac / PrintJSON.java
Created July 20, 2019 13:31
To print JSON from a httpserverletrequest in Java
StringBuilder sb = new StringBuilder();
BufferedReader reader = request.getReader();
try {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append('\n');
}
} finally {
reader.close();
}
@baymac
baymac / Shortcuts.md
Last active August 19, 2019 13:45
Generally shortcuts I use
  1. Exit from JShell - /exit

  2. To release Jenkins plugin - mvn release:prepare release:perform

  3. Open markdown preview in vs code - ctrl + k then v

#include<ssss.h>
#include<Entropy.h>
#include <gf256.h> // Not Used
FamilyId id = {5, 2};
Ssss s;
void setup() {
Serial.begin(9600);
Entropy.initialize();
@baymac
baymac / gitlabbs.md
Last active November 30, 2020 08:09
Notes for GitLab Branch Source Development

GitLabSCMSource

  • Inside getRemote() method is the set variables in the uri template okay?

  • In retrieve(head,listener) using a different version of getBranch(project, head.getName()) and not supplying username like gitea plugin. Recheck if it still works.

  • Unable to get sha of gitlab mr head. No api call for that. So used mr.getSha() instead of mr.getHead().getSha().

^ Fixed it by getting the head sha by mr.getDiffRef().getHeadSha().

  • See how head is populated in retrieve(head,listener).
@baymac
baymac / pom.xml
Last active June 18, 2019 00:49
POM for GitLab Branch Source
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.43</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running InjectedTest
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 40.508 s - in InjectedTest
[INFO] Running io.jenkins.plugins.gitlabserverconfig.casc.ConfigurationAsCodeTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.354 s <<< FAILURE! - in io.jenkins.plugins.gitlabserverconfig.casc.ConfigurationAsCodeTest
[ERROR] io.jenkins.plugins.gitlabserverconfig.casc.ConfigurationAsCodeTest Time elapsed: 2.354 s <<< FAILURE!
java.lang.AssertionError: Unexpected exception
at io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule.before(JenkinsConfiguredWithCodeRule.java:38)
at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:551)
[INFO] --- spotbugs-maven-plugin:3.1.11:check (spotbugs) @ gitlab-branch-source ---
[INFO] BugInstance size is 2
[INFO] Error size is 0
[INFO] Total bugs: 2
[ERROR] Unread field: io.jenkins.plugins.gitlabserver.credentials.PersonalAccessTokenImpl$DescriptorImpl.GITLAB_ACCESS_TOKEN_LENGTH; should this field be static? [io.jenkins.plugins.gitlabserver.credentials.PersonalAccessTokenImpl$DescriptorImpl] At PersonalAccessTokenImpl.java:[line 67] SS_SHOULD_BE_STATIC
[ERROR] Inconsistent synchronization of io.jenkins.plugins.gitlabserver.servers.GitLabServers.servers; locked 80% of time [io.jenkins.plugins.gitlabserver.servers.GitLabServers, io.jenkins.plugins.gitlabserver.servers.GitLabServers, io.jenkins.plugins.gitlabserver.servers.GitLabServers, io.jenkins.plugins.gitlabserver.servers.GitLabServers, io.jenkins.plugins.gitlabserver.servers.GitLabServers] Unsynchronized access at GitLabServers.java:[line 48]Synchronized access at GitLabServers.java:[line 111]Synchronized access at GitLabServers.java:[line 84]Sync
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error reading /home/parichay/.m2/repository/org/jenkins-ci/main/jenkins-core/2.138.4/jenkins-core-2.138.4.jar; zip file is empty
[ERROR] error reading /home/parichay/.m2/repository/org/jenkins-ci/main/jenkins-core/2.138.4/jenkins-core-2.138.4.jar; zip file is empty
[ERROR] /home/parichay/random codes/gitlab-branch-source-plugin-1/src/main/java/io/jenkins/plugins/gitlabserver/servers/GitLabServer.java:[36,1] cannot access hudson.model.Descriptor
class file for hudson.model.Descriptor not found
[ERROR] /home/parichay/random codes/gitlab-branch-source-plugin-1/src/main/java/io/jenkins/plugins/gitlabserver/credentials/PersonalAccessTokenImpl.java:[25,8] cannot access hudson.model.Describable
class file for hudson.model.Describable not found
[ERROR] /home/parichay/random codes/gitlab-branch-source-plugin-1/src/main/java/io/jenkins/plugins/gitlabserver/credentials/PersonalAccessTokenImpl.java:[65,19] cannot
@baymac
baymac / VS Code essentials.md
Last active May 22, 2019 09:06
Contains shortcuts and tricks for faster development on VS Code

Open terminal

Ctrl + ` - Within VS Code

Ctrl + Shift + C - External terminal

To avoid replacing new tabs by older ones

This is a hacky solution - Press Ctrl + C before opening a new tab