Jenkins 에서 빌드 후 조치 등에 E-mail Notification 설정을 하고, 빌드 오류시점에 E-mail 을 받아보려고 설정을 하는데, 실제로 동작을 안하고 java 관련 에러등이 나타나는경우가 있다.

참고: Jenkins Email 관련 Extention

오류내용을 보면 java.net, javax.net, javax.mail 등의 에러가 있는데, 다음 부분을 일단 확인해본다.

  • sendmail 패키지 설치되어있는지 확인
    • Jenkins Mail Extension 은 내부적으로 JavaMail 과 같은 메일 전송 에이전트를 통하는데, 시스템에 해당 패키지가 없다면 설치가 필요하다.
    • 설치가 안되었다면 yum -y install sendmail 명령어등으로 설치한다.
    • $ systemctl status sendmail
    • $ systemctl restart sendmail
  • Port 확인
    • SMTP 를 사용한다면 25번 포트가 열려있는지 확인하고, SSL 을 사용한다면 587번 포트가 열려있는지 확인한다.
  • SMTP Authentication 을 사용하는 경우
    • 해당 E-mail의 user name / password 가 제대로 입력되어있는지 확인한다.
Posted by leechwin
,

Git clone 시에 다른 organization 이나 다른 team 의 repo 를 clone 할때 다음과 같은 에러가 발생하는 경우가 있다.

 $git clone https://github.com/otherTeam/test.git
Cloning into 'test'...
remote: Repository not found.
fatal: repository 'https://github.com/otherTeam/test.git' not found

이때 기존에 사용했던 계정이 다른 organization 에 소속이 안된경우가 있을수 있는데 다음 부분에 파일에 내용을 살펴본다.

$cat ~/.git-credentials
https://other%40test.com:testpassword@github.com/otherTeam/test.git

위의 내용을 보면 해당 repo 에 other@test.com 이라는 계정에 testpassword 라는 암호가 저장되어있는데, clone 을 받으려는 repo 에 other@test.com 이라는 계정이 권한이 없는경우 해당 라인을 삭제한다.

이후에 원하는 repo 의 clone 을 받으려고 다시 시도하면 계정과 비번을 입력받는 창이 뜨는데, 이때 입력을 하면 제대로 clone 이 받아지게 된다.

이때 저장한 계정 정보는 위의 .git-credentails 파일에 저장되게 된다.

Posted by leechwin
,

Git merge 를 수행하는경우 conflict 가 나는 경우가 있다. 이때는 일일이 Conflict 를 수정해도 되지만, 현재 branch 나 merge 대상인 branch 의 내용을 바로 적용하면 이런 conflict 를 일괄적으로 수행하게 할 수 있다.

# git merge -X<option> <branch>
# option = ours, theirs 등등

# ex)
# -Xtheris 로 실행하면 현재 branch 와 conflict 가 발생할경우 otherBranch 브랜치 내용으로 적용
$ git merge -Xtheris otherBranch

참고
https://git-scm.com/book/ko/v2/Git-%EB%8F%84%EA%B5%AC-%EA%B3%A0%EA%B8%89-Merge
https://git-scm.com/docs/merge-strategies

Posted by leechwin
,

NPM 모듈을 사용할때 package.json 안에 dependencies 항목에 원하는 패키지를 기술한다.

이때 Git 저장소로 구성되어있는 패키지의 경우, 설정하기가 곤란한데, 간단한 방법을 알아보자.

  • ssh 로 설정 할 경우
    • 가장 무난하지만 22 번 포트가 막혀있다면 사용하기 어렵다.
  • https 로 설정 할 경우
    • user-name 과 password 를 경로에 입력하는 방법으로, 계정과 비번이 노출되는 단점이 있다.
  • 환경에 git credential 설정 후 https 로 설정 할 경우
    • user-name 과 password 를 입력하지 않아도 된다.
// ssh 로 설정 할 경우
"dependencies": {
  "my-git-module": "git+ssh://git@{package-git-url}/my-git-module#master",
}

// https 로 설정 할 경우
"dependencies": {
  "my-git-module": "git+https://{user-name}:{password}@{package-git-url}/my-git-module#master",
}

// git credential 설정 후 https 로 설정
$ git config --global user.name {user-name}
$ git config --global user.password {password}
$ git config --global --replace-all credential.helper "cache --timeout=3600"

"dependencies": {
  "my-git-module": "git+https://{package-git-url}/my-git-module#master",
}

'Web' 카테고리의 다른 글

[Javascript] String 과 Array 변환  (0) 2021.01.31
[Javascript] Number 진법 변환  (0) 2021.01.31
개발 블로그 링크  (0) 2020.07.05
[Chrome] DNS_PROBE_FINISHED_NXDOMAIN 오류  (0) 2019.04.09
[Javascript] Drag&Drop 을 막고싶은 경우  (0) 2019.02.25
Posted by leechwin
,

gitlab 이나 github 등을 이용하면서 git branch, tag, commit history 등 git repository 자체를 export 해서 다른 repository 에 import 해야할 경우가 있다.

이때 gitlab 이나 github 등의 UI 에서 export 를 제공해주는 경우도 있지만, 그러지 못한 환경일 경우, git command 로 export 하는 방법을 알아본다.

Export

1. --mirror 옵션으로 git clone

git clone --mirror {git repository url}
# ex)
$ git clone --mirror https://github.com/leechwin/leechwin.github.com
   --mirror
       Set up a mirror of the source repository. This implies --bare. Compared to --bare,
       --mirror not only maps local branches of the source to local branches of the
       target, it maps all refs (including remote-tracking branches, notes etc.) and sets
       up a refspec configuration such that all these refs are overwritten by a git remote
       update in the target repository.

2. git clone 을 수행하면 xxx.git 폴더가 생기고 다음과 같은 내용이 들어있다.

xxx.git
.
├── branches
├── config
├── description
├── HEAD
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── prepare-commit-msg.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   └── update.sample
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
│       ├── pack-bf556429f20d728f5f1e40739c8e886b0ac1eca7.idx
│       └── pack-bf556429f20d728f5f1e40739c8e886b0ac1eca7.pack
├── packed-refs
└── refs
    ├── heads
    └── tags

3. 위의 xxx.git 폴더를 압축하여 필요한곳으로 파일로 전송할 수도 있다.

Import

1. export 된 파일의 압축을 풀고 해당 xxx.git 폴더안에서 다음명령을 통해 새로운 repository 로 연동할 수 있다.

# 폴더 안으로 이동
$ cd xxx.git

# 새로운 repository 설정
$ git remote set-url --push origin {new git repository url}
# ex)
$ git remote set-url --push origin https://github.com/leechwin/new.leechwin.github.com

# 새로운 repository 에 push
$ git push --mirror

다른 Git 간에 특정 branch 를 복사하고 싶을때

# 새로 이동될 git
$ git clone {git repository url}
$ cd xxx
# 복사할 대상 git 을 upstream 으로 설정
$ git remote add upstream {git repository url}
$ git fetch upstream

# 복사할 대상 git 의 branch 로 부터 branch 생성
# git checkout -b {생성할 branch 이름} {원격 저장소의 branch 이름}
$ git checkout -b test-branch upstream/test-branch
// 새로 추가된 branch를 upstream에서 내 repository의 remote를 따라가도록 설정
$ git branch -u origin/{생성할 branch 이름}
$ git push origin
Posted by leechwin
,

Webpack 을 이용하여 번들링시에 package.json 에 기술된 모듈들은 대부분 번들링프로세싱에서 제외시키고 번들링을 한다.

{
    test: /\.(js|jsx)$/,
    // package.json 에 기술되어 설치된 npm 모듈들은 Babel 에서 제외 "/node_modules/" 하위 디렉토리
    exclude: /node_modules/,
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env']
    }
},

하지만 최근 일부 npm 모듈들은 IE11 를 지원하지 않는 모듈들도 나타나서 이런 모듈들을 포함해서 쓸경우 IE에서 실행할경우 ES6 미지원에 대한 에러가 발생하는 경우가 있다.

이런 브라우져들도 지원을 하려면 이때 package.json 에 기술되었더라도 Babel 을 이용한 번들링이 필요한데, 이때 다음과 같은 정규식 문법으로 exclude 필드에서 제외하는 방법이 있다.

{
    test: /\.(js|jsx)$/,
    // swagger-parser - v10.0.2
    // swagger-parser 의 경우 내부적으로 ES6의 모듈 2개에 대한 디펜던시를 가지고 있는데
    // 해당 모듈들을 찾아서 다음과같이 babel-loader 에 exclude 에 포함되지 않도록 설정한다
    exclude: /node_modules\/(?!(@apidevtools|@jsdevtools))/,
    loader: 'babel-loader?cacheDirectory',
    options: {
      presets: ['@babel/preset-env']
    }
},

위와같이 처리하고 Webpack 번들링을 수행하면, IE11 에서도 에러없이 ES6가 폴리필처리되어 잘 수행된다.

참고: tech.kakao.com/2020/12/01/frontend-growth-02/

Posted by leechwin
,

Centos7 에서 yum install maven 으로 maven 을 설치하면 3.0.5 버전이 설치가 된다.

이보다 높은 버전을 설치하고 싶다면 다음과 같이 수동으로 maven 을 설치해야한다.

Apache Maven 3.6.3 설치 예제

// 바이너리 다운로드
$ wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp

// /opt 폴더에 압축 해제
$ sudo tar -xzvf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt

// 소프트링크 생성
$ sudo ln -s /opt/apache-maven-3.6.3 /opt/maven

// 환경셋업 스크립트 생성
$ sudo vi /etc/profile.d/maven.sh
#JAVA 설정 되어있다면 무시
#export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

// 환경셋업 스크립트 실행
$ source /etc/profile.d/maven.sh

// Maven 버전 확인
$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven

참고: yallalabs.com/devops/how-to-install-apache-maven-centos-7-rhel-7/

Posted by leechwin
,

Javascript 에서 String 을 Array 로 변환하거나 Array 의 내용을 한줄의 String 으로 변환하는 방법

const str = 'leechwin.tistory.com';
const arr1 = str.split(''); // ["l", "e", "e", "c", "h", "w", "i", "n", ".", "t", "i", "s", "t", "o", "r", "y", ".", "c", "o", "m"]
const arr2 = str.split('.'); // ["leechwin", "tistory", "com"]

const result1 = arr1.join(''); // "leechwin.tistory.com"
const result2 = arr2.join('.'); // "leechwin.tistory.com"

 

참고

Posted by leechwin
,

Javascript 에서 숫자를 2진수, 8진수, 10진수, 16진수등으로 변환을 하고 싶을때는 Number 객체의 내장 함수를 이용 할수 있다.

 

// 10진수 9를 2진수문자로 변환
let dec = 9;
const bin = dec.toString(2); // 2진수문자 "1001"

// 2진수문자 "1001"을 10진수로 변환
dec = parseInt(bin, 2); // 10진수 9

 

 

참고

Posted by leechwin
,

문제

풀이

'Algorithms' 카테고리의 다른 글

[Programmers] 42586 기능개발  (0) 2021.01.20
[Programmers] 12939 최댓값과 최소값  (0) 2021.01.20
[Leetcode] two-sum  (0) 2021.01.16
[Programmers] 12948 핸드폰번호가리기  (0) 2021.01.15
[Programmers] 12982 예산  (0) 2021.01.15
Posted by leechwin
,