From d72e909050a8678bf524e58fbb6774a828c2e6a4 Mon Sep 17 00:00:00 2001 From: Zhaochunjiang Date: Tue, 9 May 2023 02:08:47 +0000 Subject: [PATCH 1/2] add Jenkinsfile. Signed-off-by: Zhaochunjiang --- Jenkinsfile | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..769dc5a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,116 @@ +def giteeCommentHeader = "| Check Name | Build Result | Build Details |\n| --- | --- | --- |\n" +pipeline { + agent { node { label 'xxx' } } + environment { + GITEE_TOKEN = credentials('xxxxxx') + } + + // stages + stages { + stage('prepare') { + steps { + sh '''#!/bin/bash -e + + test -f ci_tags.py && rm ci_tags.py* + wget https://gitee.com/openeuler/infrastructure/raw/master/ci/tools/ci_tags.py + python3 ci_tags.py $giteeTargetNamespace $giteeTargetRepoName $giteePullRequestIid $GITEE_TOKEN ATP + ''' + } + } + stage('Update and install rust') { + steps { + sh '''#!/bin/bash + # update repo + #sed -i "s#http://repo.openeuler.org#https://repo.huaweicloud.com/openeuler#g" /etc/yum.repos.d/openEuler.repo + sudo yum update + sudo yum install -y gcc cmake openssl openssl-devel protobuf-compiler git + export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static + export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup + + # install rustup package + cd ${HOME} + curl https://sh.rustup.rs -sSf -o rustup.sh && sh ./rustup.sh -y + source $HOME/.cargo/env && rustup update -- nightly + + # update cargo registry + cat > $HOME/.cargo/config << EOF + [source.crates-io] + registry = "https://github.com/rust-lang/crates.io-index" + replace-with = 'ustc' + + [source.ustc] + registry = "https://mirrors.ustc.edu.cn/crates.io-index" + + [http] + check-revoke = false +EOF + ''' + } + } + + stage('source code clone') { + steps { + sh '''#!/bin/bash + + git clone https://gitee.com/openeuler/signatrust.git + cd signatrust + git checkout -b pr_$giteePullRequestIid + git fetch origin pull/$giteePullRequestIid/head:master-$giteePullRequestIid + git merge --no-edit master-$giteePullRequestIid + ''' + } + } + + stage('cargo clippy') { + steps { + sh '''#!/bin/bash + + source $HOME/.cargo/env && cd signatrust + cargo +nightly clippy + ''' + } + } + + stage('cargo test') { + steps { + sh '''#!/bin/bash + + cd ignatrust + cargo +nightly test + ''' + } + } + + stage('cargo build') { + steps { + sh '''#!/bin/bash + + cd signatrust + cargo +nightly build + ''' + } + } + } + + + post { + success { + script { + comments = giteeCommentHeader + "| Infra Check | **success** :white_check_mark: | [#${currentBuild.fullDisplayName}](${env.BUILD_URL}/console) | \n" + sh "python3 ci_tags.py $giteeTargetNamespace $giteeTargetRepoName $giteePullRequestIid $GITEE_TOKEN ATS" + } + addGiteeMRComment comment: comments + echo 'succeeded!' + + } + + failure { + script { + comments = giteeCommentHeader + "| Infra Check | **failed** :x: | [#${currentBuild.fullDisplayName}](${env.BUILD_URL}/console) | \n" + sh "python3 ci_tags.py $giteeTargetNamespace $giteeTargetRepoName $giteePullRequestIid $GITEE_TOKEN ATF" + } + addGiteeMRComment comment: comments + echo 'failed!' + } + } +} \ No newline at end of file -- Gitee From 97d890012e019820ac213e4f92b0f044e78c4e7f Mon Sep 17 00:00:00 2001 From: Zhaochunjiang Date: Tue, 9 May 2023 02:17:42 +0000 Subject: [PATCH 2/2] update Jenkinsfile. Signed-off-by: Zhaochunjiang --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 769dc5a..2ea1fab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { GITEE_TOKEN = credentials('xxxxxx') } - // stages + // stages steps stages { stage('prepare') { steps { -- Gitee