-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
36 lines (35 loc) · 1.31 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
pipeline {
agent any
stages {
stage('Example') {
when {
expression {
sh "git fetch --no-tags --progress -- ${env.GIT_URL} +refs/heads/main:refs/remotes/upstream/main"
diff = sh(returnStdout: true, script: "git diff --name-only HEAD~ origin/main | grep ^py/ | sed -n '\$='").trim().length()
if ((diff > 0)) {
echo "MATCH"
return true
} else {
echo "NO_MATCH"
return false
}
}
}
steps {
echo "hello"
// sh "git diff upstream/master HEAD~"
script {
def target_branch = env.CHANGE_TARGET;
def pr_ref = env.BRANCH_NAME;
echo sh(returnStdout: true, script: 'env')
sh "git fetch --no-tags --progress -- ${env.GIT_URL} +refs/heads/main:refs/remotes/upstream/main"
//sh "git fetch -- ${env.GIT_URL} origin master:refs/remotes/origin/master"
sh "git diff --name-only HEAD~ origin/main | grep ^py/ | sed -n '\$='"
def TARGET = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
def HEAD = sh(returnStdout: true, script: "git rev-parse origin/${pr_ref}").trim()
echo "Checking for source changes between ${TARGET} (${HEAD}) and ${HEAD} (${pr_ref})...";
}
}
}
}
}