forked from manbearwiz/youtube-dl-server
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Jenkinsfile
86 lines (84 loc) · 3.55 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
pipeline {
agent any
options {
disableConcurrentBuilds()
}
stages {
stage('Checkout'){
steps {
checkout scm
}
}
stage('Linting') {
steps {
script {
sh "ruff check .";
}
}
}
stage('Prep buildx') {
steps {
script {
env.BUILDX_BUILDER = getBuildxBuilder();
}
}
}
stage('Build yt_dlp Image') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKERHUB_CREDENTIALS_USR', passwordVariable: 'DOCKERHUB_CREDENTIALS_PSW')]) {
sh 'docker login -u $DOCKERHUB_CREDENTIALS_USR -p "$DOCKERHUB_CREDENTIALS_PSW"'
}
sh """
docker buildx build \
--pull \
--builder \$BUILDX_BUILDER \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg YDLS_VERSION=`git rev-parse --short HEAD` \
--build-arg YDLS_RELEASE_DATE="`git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d %H:%M:%S'`" \
--build-arg YOUTUBE_DL=yt-dlp \
--build-arg ATOMICPARSLEY=1 \
-t nbr23/youtube-dl-server:latest \
-t nbr23/youtube-dl-server:yt-dlp \
-t nbr23/youtube-dl-server:`git rev-parse --short HEAD`-yt-dlp \
-t nbr23/youtube-dl-server:${GIT_COMMIT}-`date +%s`-yt-dlp \
-t nbr23/youtube-dl-server:yt-dlp_atomicparsley \
${ "$GIT_BRANCH" == "master" ? "--push" : ""} .
"""
}
}
stage('Build Youtube-dl Image') {
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKERHUB_CREDENTIALS_USR', passwordVariable: 'DOCKERHUB_CREDENTIALS_PSW')]) {
sh 'docker login -u $DOCKERHUB_CREDENTIALS_USR -p "$DOCKERHUB_CREDENTIALS_PSW"'
}
sh """
docker buildx build \
--pull \
--builder \$BUILDX_BUILDER \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg YDLS_VERSION=`git rev-parse --short HEAD` \
--build-arg YDLS_RELEASE_DATE="`git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d %H:%M:%S'`" \
--build-arg ATOMICPARSLEY=1 \
--build-arg YOUTUBE_DL=youtube-dl \
-t nbr23/youtube-dl-server:youtube-dl \
-t nbr23/youtube-dl-server:`git rev-parse --short HEAD`-youtube-dl \
-t nbr23/youtube-dl-server:${GIT_COMMIT}-`date +%s`-youtube-dl \
-t nbr23/youtube-dl-server:youtube-dl_atomicparsley \
${ "$GIT_BRANCH" == "master" ? "--push" : ""} .
"""
}
}
stage('Sync github repo') {
when { branch 'master' }
steps {
syncRemoteBranch('[email protected]:nbr23/youtube-dl-server.git', 'master')
}
}
}
post {
always {
sh 'docker buildx stop $BUILDX_BUILDER || true'
sh 'docker buildx rm $BUILDX_BUILDER || true'
}
}
}