forked from jenkins-x/jx-convert-jenkinsfile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjenkins-actions2.yml
92 lines (89 loc) · 3.14 KB
/
jenkins-actions2.yml
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
87
88
89
90
91
92
name: github-action.yaml file Created by m2ga
env:
SOURCECODE_JENKINS_CREDENTIAL_ID: jenking-github-wh
SOURCE_CODE_URL: https://github.com/my-research/todo-with-cicd.git
RELEASE_BRANCH: master
# setting github branch triggers: default-branch.
# for customizing: please check https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
# The Jenkinsfile contains the options directive for its pipeline. This is not converted.
Init:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: step1
run: echo clear
- name: step2
run: docker stop $(docker ps -aq)
- name: step3
run: docker rm $(docker ps -aq)
- name: step4
# The Jenkins Pipeline step deleteDir cannot be translated directly.
# You may want to consider adding a shell script to your repository that replicates its behavior.
# Original step from Jenkinsfile:
# deleteDir()
run: echo 'Invalid step deleteDir, failing' && exit 1
clone:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [Init]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: step1
# The Jenkins Pipeline step git cannot be translated directly.
# You may want to consider adding a shell script to your repository that replicates its behavior.
# Original step from Jenkinsfile:
# git(url: "$SOURCE_CODE_URL", branch: "$RELEASE_BRANCH", credentialsId: "$SOURCECODE_JENKINS_CREDENTIAL_ID")
run: echo 'Invalid step git, failing' && exit 1
- name: step2
run: ls -al
frontend_dockerizing:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [Init, clone]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: step1
run: docker build -t todo/frontend ./frontend
backend_dockerizing:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [Init, clone, frontend_dockerizing]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: step1
run: pwd
- name: step2
run: pwd
working-directory: ./backend
- name: step3
run: gradle clean
working-directory: ./backend
- name: step4
run: gradle bootJar
working-directory: ./backend
- name: step5
run: docker build -t todo/backend .
working-directory: ./backend
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [Init, clone, frontend_dockerizing, backend_dockerizing]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: step1
run: |
docker run -d -p 5000:5000 todo/frontend
docker run -d -p 8080:8080 todo/backend