Browse Source

add pipeline

tags/1.1.2
Vladimir Smagin 9 months ago
parent
commit
accc0f7b3a
10 changed files with 71 additions and 73 deletions
  1. +13
    -0
      Dockerfile
  2. +43
    -0
      Jenkinsfile
  3. +0
    -24
      build.sh
  4. +12
    -0
      build/deb/build.sh
  5. +3
    -3
      build/deb/control
  6. +0
    -0
      build/deb/debian/etc/systemd/system/gogocron.service
  7. +0
    -17
      config/gogocron.yml
  8. +0
    -14
      configs/test1.yml
  9. +0
    -10
      configs/test2.yml
  10. +0
    -5
      website/index.html

+ 13
- 0
Dockerfile View File

@@ -0,0 +1,13 @@
FROM golang:1.13-alpine

RUN apk update
RUN apk add git mercurial

WORKDIR /app
COPY . .

RUN CGO_ENABLED=0 go build -mod=vendor

FROM alpine:3.11

COPY --from=0 /app/gogocron /usr/bin/gogocron

+ 43
- 0
Jenkinsfile View File

@@ -0,0 +1,43 @@
node {
checkout scm

def registry = "registry.blindage.org"
def tag = env.TAG_NAME
def image
def repository = "gogocron"
def image_name = "${repository}:${tag}"

stage("Build app binary") {
sh "docker run --rm -v jenkins_jenkins-data:/var/jenkins_home golang:1.13-alpine /bin/sh -c 'cd ${WORKSPACE} && go build -mod vendor'"
}

stage("Build app image") {
try {
sh "docker build -t ${image_name} ."
image = docker.image(image_name)
} catch (Exception e) {
error("Failed to build image")
}
}

stage("Build deb package") {
sh "./build/deb/build.sh"
archiveArtifacts "gogocron-${tag}.deb"
sh "mv *.deb /var/packages/"
}

stage("Push Image") {
try {

docker.withRegistry("https://${registry}", "registry") {
image.push()
}

} catch(Exception e) {
error("Failed to push image")
} finally {
sh "docker rmi ${registry}/${image_name} || true"
}
}

}

+ 0
- 24
build.sh View File

@@ -1,24 +0,0 @@
#!/bin/bash

VERSION="1.1.1"

# build gogocron
go build

# prepage control file

sed -i "s/Version.*/Version: ${VERSION}/" ./debian/DEBIAN/control

# copy files to deb package structure
mkdir -p ./debian/etc/gogocron
mkdir -p ./debian/usr/bin
mkdir -p ./debian/usr/share/gogocron/samples/
mkdir -p ./debian/DEBIAN

cp gogocron ./debian/usr/bin/
cp config/gogocron.yml ./debian/etc/gogocron/
cp configs/*.yml ./debian/usr/share/gogocron/samples/

# build deb package
dpkg-deb --build debian gogocron-${VERSION}.deb


+ 12
- 0
build/deb/build.sh View File

@@ -0,0 +1,12 @@
#!/bin/bash
VERSION=${TAG_NAME}
mkdir -p ./build/deb/debian/usr/bin
mkdir -p ./build/deb/debian/DEBIAN/
mv ./gogocron ./build/deb/debian/usr/bin/
DSIZE=$(du -hs ./build/deb/debian/usr/bin|awk '{ print $1 }')
echo "Making deb config"
cp ./build/deb/control ./build/deb/debian/DEBIAN/control
sed -i "s/VERSION/${VERSION}/g" ./build/deb/debian/DEBIAN/control
sed -i "s/DSIZE/${DSIZE}/g" ./build/deb/debian/DEBIAN/control
echo "Building deb package"
dpkg-deb --build ./build/deb/debian ./gogocron-${VERSION}.deb

debian/DEBIAN/control → build/deb/control View File

@@ -1,12 +1,12 @@
Package: gogocron
Version: 1.1.1
Version: VERSION
Section: base
Priority: optional
Installed-Size: 3 MB
Installed-Size: DSIZE
Architecture: amd64
Depends: coreutils (>= 5.0-5)
Maintainer: Vladimir Smagin <21h@blindage.org>
Homepage: http://gogocron.blindage.org
Homepage: https://git.blindage.org/21h/gogocron
Description: Cron daemon for Linux with 1 second minimal interval
This package provides gogocron daemon, that can run tasks with 1s
minimal interval and execution timeout. Higly configurable tasks with

debian/etc/systemd/system/gogocron.service → build/deb/debian/etc/systemd/system/gogocron.service View File


+ 0
- 17
config/gogocron.yml View File

@@ -1,17 +0,0 @@
---
# ticktack_precision
#
# Precision means how frequently gogocron checks seconds number change. Lower
# interval gets more resources because check circle works faster. This parameter
# created for high precision requirements where maximum cron run time deviation
# can't be more than 10 ms.
#
# Value (milliseconds) from 10ms to 500ms
# default: 100ms
ticktack_precision: 100ms

# tasks_location
# Set where tasks yaml files located
# Value (string)
# default: /etc/gogocron/configs
tasks_location: /etc/gogocron/configs

+ 0
- 14
configs/test1.yml View File

@@ -1,14 +0,0 @@
---
name: "TASK #1"
runsecond: "*/5"
logtype: full
user: vlad
gracefulstop: 30s
env:
- TESTVAR="test variable"
commands:
- whoami
- sleep 3
- head -c 20 /dev/urandom |base64
- ls
- echo $TESTVAR

+ 0
- 10
configs/test2.yml View File

@@ -1,10 +0,0 @@
---
name: "TASK #2"
runsecond: "*/15"
timeout: 1s
logtype: full
user: root
commands:
- "head -c 2 /dev/urandom |base64"
- "sleep 2"
- "echo ooops"

+ 0
- 5
website/index.html View File

@@ -1,5 +0,0 @@
<html>
<head>
<meta http-equiv="refresh" content="1;URL=https://git.blindage.org/21h/gogocron" />
</head>
</html>

Loading…
Cancel
Save